Skip to content

Commit cf89016

Browse files
mhiramatopsiff
authored andcommitted
kprobes: Remove unneeded goto
[ Upstream commit 5e5b8b4 ] Remove unneeded gotos. Since the labels referred by these gotos have only one reference for each, we can replace those gotos with the referred code. Link: https://lore.kernel.org/all/173371211203.480397.13988907319659165160.stgit@devnote2/ Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Stable-dep-of: 5ef268cb7a0a ("kprobes: Remove unneeded warnings from __arm_kprobe_ftrace()") Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit 61cfa81f19b95c8330fc0a3eb8f6039e3b27b790) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
1 parent b43e297 commit cf89016

1 file changed

Lines changed: 21 additions & 24 deletions

File tree

kernel/kprobes.c

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,20 +1083,18 @@ static int __arm_kprobe_ftrace(struct kprobe *p, struct ftrace_ops *ops,
10831083

10841084
if (*cnt == 0) {
10851085
ret = register_ftrace_function(ops);
1086-
if (WARN(ret < 0, "Failed to register kprobe-ftrace (error %d)\n", ret))
1087-
goto err_ftrace;
1086+
if (WARN(ret < 0, "Failed to register kprobe-ftrace (error %d)\n", ret)) {
1087+
/*
1088+
* At this point, sinec ops is not registered, we should be sefe from
1089+
* registering empty filter.
1090+
*/
1091+
ftrace_set_filter_ip(ops, (unsigned long)p->addr, 1, 0);
1092+
return ret;
1093+
}
10881094
}
10891095

10901096
(*cnt)++;
10911097
return ret;
1092-
1093-
err_ftrace:
1094-
/*
1095-
* At this point, sinec ops is not registered, we should be sefe from
1096-
* registering empty filter.
1097-
*/
1098-
ftrace_set_filter_ip(ops, (unsigned long)p->addr, 1, 0);
1099-
return ret;
11001098
}
11011099

11021100
static int arm_kprobe_ftrace(struct kprobe *p)
@@ -1457,7 +1455,7 @@ _kprobe_addr(kprobe_opcode_t *addr, const char *symbol_name,
14571455
unsigned long offset, bool *on_func_entry)
14581456
{
14591457
if ((symbol_name && addr) || (!symbol_name && !addr))
1460-
goto invalid;
1458+
return ERR_PTR(-EINVAL);
14611459

14621460
if (symbol_name) {
14631461
/*
@@ -1487,11 +1485,10 @@ _kprobe_addr(kprobe_opcode_t *addr, const char *symbol_name,
14871485
* at the start of the function.
14881486
*/
14891487
addr = arch_adjust_kprobe_addr((unsigned long)addr, offset, on_func_entry);
1490-
if (addr)
1491-
return addr;
1488+
if (!addr)
1489+
return ERR_PTR(-EINVAL);
14921490

1493-
invalid:
1494-
return ERR_PTR(-EINVAL);
1491+
return addr;
14951492
}
14961493

14971494
static kprobe_opcode_t *kprobe_addr(struct kprobe *p)
@@ -1514,15 +1511,15 @@ static struct kprobe *__get_valid_kprobe(struct kprobe *p)
15141511
if (unlikely(!ap))
15151512
return NULL;
15161513

1517-
if (p != ap) {
1518-
list_for_each_entry(list_p, &ap->list, list)
1519-
if (list_p == p)
1520-
/* kprobe p is a valid probe */
1521-
goto valid;
1522-
return NULL;
1523-
}
1524-
valid:
1525-
return ap;
1514+
if (p == ap)
1515+
return ap;
1516+
1517+
list_for_each_entry(list_p, &ap->list, list)
1518+
if (list_p == p)
1519+
/* kprobe p is a valid probe */
1520+
return ap;
1521+
1522+
return NULL;
15261523
}
15271524

15281525
/*

0 commit comments

Comments
 (0)