[Devel] [PATCH hci-8.2 5/6] ms/klp-build: Fix wrong index in funcs cleanup error path

Konstantin Khorenko khorenko at virtuozzo.com
Fri Nov 27 00:51:20 MSK 2026


From: Yafang Shao <laoar.shao at gmail.com>

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: 59adee07b568 ("livepatch/klp-build: Add stub init code for livepatch modules")
Signed-off-by: Yafang Shao <laoar.shao at gmail.com>
Acked-by: Song Liu <song at kernel.org>
Reviewed-by: Petr Mladek <pmladek at suse.com>
Acked-by: Miroslav Benes <mbenes at suse.cz>
Link: https://patch.msgid.link/20260816090442.18128-2-laoar.shao@gmail.com
Signed-off-by: Josh Poimboeuf <jpoimboe at kernel.org>
(cherry picked from commit 4825ef699cda4c6f2f0586b17a5e225560481da6)

https://virtuozzo.atlassian.net/browse/VSTOR-157128
Feature: klp-build support
Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
 scripts/livepatch/init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/livepatch/init.c b/scripts/livepatch/init.c
index 2274d8f5a4826..8586e6d4efbff 100644
--- a/scripts/livepatch/init.c
+++ b/scripts/livepatch/init.c
@@ -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;
 		}
 

-- 
2.43.0



More information about the Devel mailing list