Re: [PATCH v4 11/11] liveupdate: fix return value on session allocation failure

Pasha Tatashin
2026-04-15T18:44:21Z

On Wed, Apr 15, 2026 at 11:42 AM Mike Rapoport <rppt@kernel.org> wrote:
>
> On Mon, Apr 13, 2026 at 06:51:27PM +0000, Pasha Tatashin wrote:
> > When session allocation fails during deserialization, the global 'err'
> > variable was not updated before returning. This caused subsequent calls
> > to luo_session_deserialize() to incorrectly report success.
> >
> > Ensure 'err' is set to the error code from PTR_ERR(session). This
> > ensures that an error is correctly returned to userspace when it
> > attempts to open /dev/liveupdate in the new kernel if deserialization
> > failed.
> >
> > Signed-off-by: Pasha Tatashin <pasha.tatashin@soleen.com>
> > ---
> > kernel/liveupdate/luo_session.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/kernel/liveupdate/luo_session.c b/kernel/liveupdate/luo_session.c
> > index a3327a28fc1f..92b1af791889 100644
> > --- a/kernel/liveupdate/luo_session.c
> > +++ b/kernel/liveupdate/luo_session.c
> > @@ -547,7 +547,8 @@ int luo_session_deserialize(void)
> > pr_warn("Failed to allocate session [%.*s] during deserialization %pe\n",
> > (int)sizeof(sh->ser[i].name),
> > sh->ser[i].name, session);
> > - return PTR_ERR(session);
> > + err = PTR_ERR(session);
>
> it's really not obvious that err is global and it should be set before
> returning.
>
> I'd suggest replacing all return with goto that will return err;
> This way it should be clearer that since err is returned it should be set.

SGTM, I will send a new patch as reply to this e-mail, instead of
re-sending the full series.

Pasha

>
> > + return err;
> > }
> >
> > err = luo_session_insert(sh, session);
> > --
> > 2.43.0
> >
>
> --
> Sincerely yours,
> Mike.