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

From: Miroslav Benes

Date: Fri Aug 28 2026 - 03:19:31 EST


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@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?
>
> 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