mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-30 22:26:55 +00:00
rethook: fix a potential memleak in rethook_alloc()
commit0a1ebe35cb
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@huawei.com/ [Masami: Add "rethook:" tag to the title.] Fixes:54ecbe6f1e
("rethook: Add a generic return hook") Cc: stable@vger.kernel.org Signed-off-by: Yi Yang <yiyang13@huawei.com> Acke-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
510c12f936
commit
cbc5d1f9a8
1 changed files with 3 additions and 1 deletions
|
@ -83,8 +83,10 @@ struct rethook *rethook_alloc(void *data, rethook_handler_t handler)
|
|||
{
|
||||
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;
|
||||
|
|
Loading…
Reference in a new issue