Skip to content

Commit d05ea35

Browse files
rafaelmsoaresmhiramat
authored andcommitted
fprobe: Check rethook_alloc() return in rethook initialization
Check if fp->rethook succeeded to be allocated. Otherwise, if rethook_alloc() fails, then we end up dereferencing a NULL pointer in rethook_add_node(). Link: https://lore.kernel.org/all/[email protected]/ Fixes: 5b0ab78 ("fprobe: Add exit_handler support") Cc: [email protected] Signed-off-by: Rafael Mendonca <[email protected]> Acked-by: Steven Rostedt (Google) <[email protected]> Acked-by: Masami Hiramatsu (Google) <[email protected]> Signed-off-by: Masami Hiramatsu (Google) <[email protected]>
1 parent 4a6f316 commit d05ea35

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

kernel/trace/fprobe.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ static int fprobe_init_rethook(struct fprobe *fp, int num)
141141
return -E2BIG;
142142

143143
fp->rethook = rethook_alloc((void *)fp, fprobe_exit_handler);
144+
if (!fp->rethook)
145+
return -ENOMEM;
144146
for (i = 0; i < size; i++) {
145147
struct fprobe_rethook_node *node;
146148

0 commit comments

Comments
 (0)