mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-09-18 22:09:30 +02:00
klp-build: Fix wrong index in funcs cleanup error path
In the object allocation loop, when kzalloc() for funcs fails, the
cleanup loop uses `objs[i].funcs` instead of `objs[j].funcs`. Since
`objs[i].funcs` is still NULL at that point, it repeatedly calls
kfree(NULL) and leaks all previously allocated funcs arrays.
Fixes: 59adee07b5 ("livepatch/klp-build: Add stub init code for livepatch modules")
Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
Acked-by: Song Liu <song@kernel.org>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Acked-by: Miroslav Benes <mbenes@suse.cz>
Link: https://patch.msgid.link/20260816090442.18128-2-laoar.shao@gmail.com
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
This commit is contained in:
committed by
Josh Poimboeuf
parent
cee9395acd
commit
4825ef699c
@@ -51,7 +51,7 @@ static int __init livepatch_mod_init(void)
|
||||
if (!funcs) {
|
||||
ret = -ENOMEM;
|
||||
for (int j = 0; j < i; j++)
|
||||
kfree(objs[i].funcs);
|
||||
kfree(objs[j].funcs);
|
||||
goto err_free_objs;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user