Skip to content

Commit 6049674

Browse files
committed
tracing: fprobe: Initialize ret valiable to fix smatch error
The commit 39d9542 ("fprobe: Skip exit_handler if entry_handler returns !0") introduced a hidden dependency of 'ret' local variable in the fprobe_handler(), Smatch warns the `ret` can be accessed without initialization. kernel/trace/fprobe.c:59 fprobe_handler() error: uninitialized symbol 'ret'. kernel/trace/fprobe.c 49 fpr->entry_ip = ip; 50 if (fp->entry_data_size) 51 entry_data = fpr->data; 52 } 53 54 if (fp->entry_handler) 55 ret = fp->entry_handler(fp, ip, ftrace_get_regs(fregs), entry_data); ret is only initialized if there is an ->entry_handler 56 57 /* If entry_handler returns !0, nmissed is not counted. */ 58 if (rh) { rh is only true if there is an ->exit_handler. Presumably if you have and ->exit_handler that means you also have a ->entry_handler but Smatch is not smart enough to figure it out. --> 59 if (ret) ^^^ Warning here. 60 rethook_recycle(rh); 61 else 62 rethook_hook(rh, ftrace_get_regs(fregs), true); 63 } 64 out: 65 ftrace_test_recursion_unlock(bit); 66 } Link: https://lore.kernel.org/all/168100731160.79534.374827110083836722.stgit@devnote2/ Reported-by: Dan Carpenter <[email protected]> Link: https://lore.kernel.org/all/[email protected] Fixes: 39d9542 ("fprobe: Skip exit_handler if entry_handler returns !0") Acked-by: Dan Carpenter <[email protected]> Signed-off-by: Masami Hiramatsu (Google) <[email protected]>
1 parent ac9a786 commit 6049674

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/trace/fprobe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ static void fprobe_handler(unsigned long ip, unsigned long parent_ip,
2727
struct rethook_node *rh = NULL;
2828
struct fprobe *fp;
2929
void *entry_data = NULL;
30-
int bit, ret;
30+
int bit, ret = 0;
3131

3232
fp = container_of(ops, struct fprobe, ops);
3333
if (fprobe_disabled(fp))

0 commit comments

Comments
 (0)