Re: [PATCH v4 11/11] liveupdate: fix return value on session allocation failure
From: Mike Rapoport
Date: Wed Apr 15 2026 - 11:47:25 EST
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@xxxxxxxxxx>
> ---
> 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.
> + return err;
> }
>
> err = luo_session_insert(sh, session);
> --
> 2.43.0
>
--
Sincerely yours,
Mike.