summaryrefslogtreecommitdiff
path: root/samples
diff options
context:
space:
mode:
authorTiezhu Yang <yangtiezhu@loongson.cn>2021-10-26 09:51:28 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-11-17 09:48:39 +0100
commit3f3b4054e214a7555b048b4e70e6c2211a3fb2ab (patch)
tree5e30b0b87678df631b2d0071022eb64599371fff /samples
parent9435b2f9c006282fc134aae51596a714dd890d6e (diff)
samples/kretprobes: Fix return value if register_kretprobe() failed
[ Upstream commit f76fbbbb5061fe14824ba5807c44bd7400a6b4e1 ] 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 Fixes: 804defea1c02 ("Kprobes: move kprobe examples to samples/") Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn> Acked-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'samples')
-rw-r--r--samples/kprobes/kretprobe_example.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/samples/kprobes/kretprobe_example.c b/samples/kprobes/kretprobe_example.c
index 186315ca88b3..2701549ee7b3 100644
--- a/samples/kprobes/kretprobe_example.c
+++ b/samples/kprobes/kretprobe_example.c
@@ -84,7 +84,7 @@ static int __init kretprobe_init(void)
ret = register_kretprobe(&my_kretprobe);
if (ret < 0) {
pr_err("register_kretprobe failed, returned %d\n", ret);
- return -1;
+ return ret;
}
pr_info("Planted return probe at %s: %p\n",
my_kretprobe.kp.symbol_name, my_kretprobe.kp.addr);