History

samples/kretprobes: Fix return value if register_kretprobe() failed

Use the actual return value instead of always -1 if register_kretprobe() failed. E.g. without this patch: # insmod samples/kprobes/kretprobe_example.ko func=no_such_func insmod: ERROR: could not insert module samples/kprobes/kretprobe_example.ko: Operation not permitted With this patch: # insmod samples/kprobes/kretprobe_example.ko func=no_such_func insmod: ERROR: could not insert module samples/kprobes/kretprobe_example.ko: Unknown symbol in module Link: https://lkml.kernel.org/r/1635213091-24387-2-git-send-email-yangtiezhu@loongson.cn

Tiezhu Yang committed 5 years ago

Commit f76fbbb1 parent 010db091 file · +1 −1Browse files

Unified · Split

samples/kprobes/kretprobe_example.c+1−1
@@ -86,7 +86,7 @@ static int __init kretprobe_init(void) · 85 unmodified lines
86 ret = register_kretprobe(&my_kretprobe);86 ret = register_kretprobe(&my_kretprobe);
87 if (ret < 0) {87 if (ret < 0) {
88 pr_err("register_kretprobe failed, returned %d\n", ret);88 pr_err("register_kretprobe failed, returned %d\n", ret);
89 return -1;89 return ret;
90 }90 }
91 pr_info("Planted return probe at %s: %p\n",91 pr_info("Planted return probe at %s: %p\n",
92 my_kretprobe.kp.symbol_name, my_kretprobe.kp.addr);92 my_kretprobe.kp.symbol_name, my_kretprobe.kp.addr);