Skip to content

Commit 0a1ebe3

Browse files
Yi Yangmhiramat
authored andcommitted
rethook: fix a potential memleak in rethook_alloc()
In rethook_alloc(), the variable rh is not freed or passed out if handler is NULL, which could lead to a memleak, fix it. Link: https://lore.kernel.org/all/[email protected]/ [Masami: Add "rethook:" tag to the title.] Fixes: 54ecbe6 ("rethook: Add a generic return hook") Cc: [email protected] Signed-off-by: Yi Yang <[email protected]> Acke-by: Masami Hiramatsu (Google) <[email protected]> Signed-off-by: Masami Hiramatsu (Google) <[email protected]>
1 parent d1776c0 commit 0a1ebe3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

kernel/trace/rethook.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,10 @@ struct rethook *rethook_alloc(void *data, rethook_handler_t handler)
8383
{
8484
struct rethook *rh = kzalloc(sizeof(struct rethook), GFP_KERNEL);
8585

86-
if (!rh || !handler)
86+
if (!rh || !handler) {
87+
kfree(rh);
8788
return NULL;
89+
}
8890

8991
rh->data = data;
9092
rh->handler = handler;

0 commit comments

Comments
 (0)