Re: [PATCH] livepatch/klp-build: Fix wrong index in error cleanup loop

From: Miroslav Benes

Date: Mon Aug 24 2026 - 09:48:41 EST


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@xxxxxxx>
>
> Great catch!
>
> Reviewed-by: Petr Mladek <pmladek@xxxxxxxx>
>
> 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