* [PATCH] livepatch/klp-build: Fix wrong index in error cleanup loop
@ 2026-07-01 6:06 Shihao Ren
2026-07-01 11:16 ` Miroslav Benes
2026-07-02 8:53 ` Petr Mladek
0 siblings, 2 replies; 3+ messages in thread
From: Shihao Ren @ 2026-07-01 6:06 UTC (permalink / raw)
To: jpoimboe, jikos, mbenes, pmladek
Cc: joe.lawrence, live-patching, linux-kernel, Shihao Ren
In the funcs allocation failure path, the cleanup loop iterates with
'j' but frees objs[i].funcs, which uses the outer loop index 'i'
instead of the loop variable 'j'. As a result the just-failed (NULL)
entry is freed repeatedly, while the funcs buffers already allocated
for objs[0..i-1] are leaked.
Use objs[j].funcs so the previously allocated entries are correctly
released.
Fixes: 59adee07b568 ("livepatch/klp-build: Add stub init code for livepatch modules")
Signed-off-by: Shihao Ren <rsh15355756202@163.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 f14d8c8fb..16aff8f73 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.39.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] livepatch/klp-build: Fix wrong index in error cleanup loop
2026-07-01 6:06 [PATCH] livepatch/klp-build: Fix wrong index in error cleanup loop Shihao Ren
@ 2026-07-01 11:16 ` Miroslav Benes
2026-07-02 8:53 ` Petr Mladek
1 sibling, 0 replies; 3+ messages in thread
From: Miroslav Benes @ 2026-07-01 11:16 UTC (permalink / raw)
To: Shihao Ren
Cc: jpoimboe, jikos, pmladek, joe.lawrence, live-patching,
linux-kernel
On Wed, 1 Jul 2026, Shihao Ren wrote:
> In the funcs allocation failure path, the cleanup loop iterates with
> 'j' but frees objs[i].funcs, which uses the outer loop index 'i'
> instead of the loop variable 'j'. As a result the just-failed (NULL)
> entry is freed repeatedly, while the funcs buffers already allocated
> for objs[0..i-1] are leaked.
>
> Use objs[j].funcs so the previously allocated entries are correctly
> released.
>
> Fixes: 59adee07b568 ("livepatch/klp-build: Add stub init code for livepatch modules")
> Signed-off-by: Shihao Ren <rsh15355756202@163.com>
Acked-by: Miroslav Benes <mbenes@suse.cz>
M
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] livepatch/klp-build: Fix wrong index in error cleanup loop
2026-07-01 6:06 [PATCH] livepatch/klp-build: Fix wrong index in error cleanup loop Shihao Ren
2026-07-01 11:16 ` Miroslav Benes
@ 2026-07-02 8:53 ` Petr Mladek
1 sibling, 0 replies; 3+ messages in thread
From: Petr Mladek @ 2026-07-02 8:53 UTC (permalink / raw)
To: Shihao Ren
Cc: jpoimboe, jikos, mbenes, joe.lawrence, live-patching,
linux-kernel
On Wed 2026-07-01 14:06:55, Shihao Ren wrote:
> In the funcs allocation failure path, the cleanup loop iterates with
> 'j' but frees objs[i].funcs, which uses the outer loop index 'i'
> instead of the loop variable 'j'. As a result the just-failed (NULL)
> entry is freed repeatedly, while the funcs buffers already allocated
> for objs[0..i-1] are leaked.
>
> Use objs[j].funcs so the previously allocated entries are correctly
> released.
>
> Fixes: 59adee07b568 ("livepatch/klp-build: Add stub init code for livepatch modules")
> Signed-off-by: Shihao Ren <rsh15355756202@163.com>
Great catch!
Reviewed-by: Petr Mladek <pmladek@suse.com>
I assume that Josh would take this together with other klp-build
related changes.
Best Regards,
Petr
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-07-02 8:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-01 6:06 [PATCH] livepatch/klp-build: Fix wrong index in error cleanup loop Shihao Ren
2026-07-01 11:16 ` Miroslav Benes
2026-07-02 8:53 ` Petr Mladek
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.