This is a note to let you know that I've just added the patch titled rethook: fix a potential memleak in rethook_alloc() to the 6.0-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: rethook-fix-a-potential-memleak-in-rethook_alloc.patch and it can be found in the queue-6.0 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 0a1ebe35cb3b7aa1f4b26b37e2a0b9ae68dc4ffb Mon Sep 17 00:00:00 2001 From: Yi Yang <yiyang13@xxxxxxxxxx> Date: Fri, 18 Nov 2022 10:15:34 +0900 Subject: rethook: fix a potential memleak in rethook_alloc() From: Yi Yang <yiyang13@xxxxxxxxxx> commit 0a1ebe35cb3b7aa1f4b26b37e2a0b9ae68dc4ffb upstream. 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/20221110104438.88099-1-yiyang13@xxxxxxxxxx/ [Masami: Add "rethook:" tag to the title.] Fixes: 54ecbe6f1ed5 ("rethook: Add a generic return hook") Cc: stable@xxxxxxxxxxxxxxx Signed-off-by: Yi Yang <yiyang13@xxxxxxxxxx> Acke-by: Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx> Signed-off-by: Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- kernel/trace/rethook.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/kernel/trace/rethook.c +++ b/kernel/trace/rethook.c @@ -83,8 +83,10 @@ struct rethook *rethook_alloc(void *data { struct rethook *rh = kzalloc(sizeof(struct rethook), GFP_KERNEL); - if (!rh || !handler) + if (!rh || !handler) { + kfree(rh); return NULL; + } rh->data = data; rh->handler = handler; Patches currently in stable-queue which might be from yiyang13@xxxxxxxxxx are queue-6.0/rethook-fix-a-potential-memleak-in-rethook_alloc.patch