Skip to content

Commit 5e5b8b4

Browse files
committed
kprobes: Remove unneeded goto
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>
1 parent a35fb2b commit 5e5b8b4

File tree

1 file changed

+21
-24
lines changed

1 file changed

+21
-24
lines changed

kernel/kprobes.c

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

10721072
if (*cnt == 0) {
10731073
ret = register_ftrace_function(ops);
1074-
if (WARN(ret < 0, "Failed to register kprobe-ftrace (error %d)\n", ret))
1075-
goto err_ftrace;
1074+
if (WARN(ret < 0, "Failed to register kprobe-ftrace (error %d)\n", ret)) {
1075+
/*
1076+
* At this point, sinec ops is not registered, we should be sefe from
1077+
* registering empty filter.
1078+
*/
1079+
ftrace_set_filter_ip(ops, (unsigned long)p->addr, 1, 0);
1080+
return ret;
1081+
}
10761082
}
10771083

10781084
(*cnt)++;
10791085
return ret;
1080-
1081-
err_ftrace:
1082-
/*
1083-
* At this point, sinec ops is not registered, we should be sefe from
1084-
* registering empty filter.
1085-
*/
1086-
ftrace_set_filter_ip(ops, (unsigned long)p->addr, 1, 0);
1087-
return ret;
10881086
}
10891087

10901088
static int arm_kprobe_ftrace(struct kprobe *p)
@@ -1428,7 +1426,7 @@ _kprobe_addr(kprobe_opcode_t *addr, const char *symbol_name,
14281426
unsigned long offset, bool *on_func_entry)
14291427
{
14301428
if ((symbol_name && addr) || (!symbol_name && !addr))
1431-
goto invalid;
1429+
return ERR_PTR(-EINVAL);
14321430

14331431
if (symbol_name) {
14341432
/*
@@ -1458,11 +1456,10 @@ _kprobe_addr(kprobe_opcode_t *addr, const char *symbol_name,
14581456
* at the start of the function.
14591457
*/
14601458
addr = arch_adjust_kprobe_addr((unsigned long)addr, offset, on_func_entry);
1461-
if (addr)
1462-
return addr;
1459+
if (!addr)
1460+
return ERR_PTR(-EINVAL);
14631461

1464-
invalid:
1465-
return ERR_PTR(-EINVAL);
1462+
return addr;
14661463
}
14671464

14681465
static kprobe_opcode_t *kprobe_addr(struct kprobe *p)
@@ -1486,15 +1483,15 @@ static struct kprobe *__get_valid_kprobe(struct kprobe *p)
14861483
if (unlikely(!ap))
14871484
return NULL;
14881485

1489-
if (p != ap) {
1490-
list_for_each_entry(list_p, &ap->list, list)
1491-
if (list_p == p)
1492-
/* kprobe p is a valid probe */
1493-
goto valid;
1494-
return NULL;
1495-
}
1496-
valid:
1497-
return ap;
1486+
if (p == ap)
1487+
return ap;
1488+
1489+
list_for_each_entry(list_p, &ap->list, list)
1490+
if (list_p == p)
1491+
/* kprobe p is a valid probe */
1492+
return ap;
1493+
1494+
return NULL;
14981495
}
14991496

15001497
/*

0 commit comments

Comments
 (0)