* [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; 6+ 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 [flat|nested] 6+ 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; 6+ 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] 6+ 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
2026-08-24 13:42 ` Miroslav Benes
1 sibling, 1 reply; 6+ 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] 6+ messages in thread
* Re: [PATCH] livepatch/klp-build: Fix wrong index in error cleanup loop
2026-07-02 8:53 ` Petr Mladek
@ 2026-08-24 13:42 ` Miroslav Benes
2026-08-27 22:49 ` Josh Poimboeuf
0 siblings, 1 reply; 6+ messages in thread
From: Miroslav Benes @ 2026-08-24 13:42 UTC (permalink / raw)
To: jpoimboe
Cc: Shihao Ren, pmladek, jikos, joe.lawrence, live-patching, linux-kernel
On Thu, 2 Jul 2026, Petr Mladek wrote:
> 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.
I do not see it merged yet. Josh, could you take it, please?
Miroslav
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] livepatch/klp-build: Fix wrong index in error cleanup loop
2026-08-24 13:42 ` Miroslav Benes
@ 2026-08-27 22:49 ` Josh Poimboeuf
2026-08-28 7:19 ` Miroslav Benes
0 siblings, 1 reply; 6+ messages in thread
From: Josh Poimboeuf @ 2026-08-27 22:49 UTC (permalink / raw)
To: Miroslav Benes
Cc: Shihao Ren, pmladek, jikos, joe.lawrence, live-patching, linux-kernel
On Mon, Aug 24, 2026 at 03:42:46PM +0200, Miroslav Benes wrote:
> On Thu, 2 Jul 2026, Petr Mladek wrote:
>
> > 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.
>
> I do not see it merged yet. Josh, could you take it, please?
Sorry, I missed seeing this one, but I do have an identical patch
already queued:
https://lore.kernel.org/aocdq0hr_iQTimG0@jpoimboe
--
Josh
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] livepatch/klp-build: Fix wrong index in error cleanup loop
2026-08-27 22:49 ` Josh Poimboeuf
@ 2026-08-28 7:19 ` Miroslav Benes
0 siblings, 0 replies; 6+ messages in thread
From: Miroslav Benes @ 2026-08-28 7:19 UTC (permalink / raw)
To: Josh Poimboeuf
Cc: Shihao Ren, pmladek, jikos, joe.lawrence, live-patching, linux-kernel
On Thu, 27 Aug 2026, Josh Poimboeuf wrote:
> On Mon, Aug 24, 2026 at 03:42:46PM +0200, Miroslav Benes wrote:
> > On Thu, 2 Jul 2026, Petr Mladek wrote:
> >
> > > 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.
> >
> > I do not see it merged yet. Josh, could you take it, please?
>
> Sorry, I missed seeing this one, but I do have an identical patch
> already queued:
>
> https://lore.kernel.org/aocdq0hr_iQTimG0@jpoimboe
Ok, thanks. I did not get that far in my INBOX after holiday yet :/
Miroslav
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-08-28 7:19 UTC | newest]
Thread overview: 6+ 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
2026-08-24 13:42 ` Miroslav Benes
2026-08-27 22:49 ` Josh Poimboeuf
2026-08-28 7:19 ` Miroslav Benes
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®