Skip to contentSkip to conversation

liveupdate: luo_session: Fix a couple Smatch issues

PATCH In review Dan Carpenter 3 participants 8 messages Nov 26, 2025 – Nov 27, 2025 Live update

lore
Share & tools
lore
#0 lore raw

cover liveupdate: luo_session: Fix a couple Smatch issues

Smatch detected these two bugs.

Dan Carpenter (2):
liveupdate: luo_session: Fix uninitialized variable in
luo_session_setup_outgoing()
liveupdate: luo_session: Fix use after free in
luo_session_deserialize()

 kernel/liveupdate/luo_session.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.51.0
#1 lore raw

PATCH 1/2 liveupdate: luo_session: Fix uninitialized variable in luo_session_setup_outgoing()

The "header_ser" variable is uninitialized. The "outgoing_buffer" variable was intended here, so use that instead.

Fixes 7eeeec7e1690 ("liveupdate: luo_session: add sessions support")
---
 kernel/liveupdate/luo_session.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/liveupdate/luo_session.c +1 -1
index cf5c83b272e7..a572bf689712 100644
@@ -447,7 +447,7 @@ int __init luo_session_setup_outgoing(void *fdt_out)
 
 	outgoing_buffer = kho_alloc_preserve(LUO_SESSION_PGCNT << PAGE_SHIFT);
 	if (IS_ERR(outgoing_buffer))
-		return PTR_ERR(header_ser);
+		return PTR_ERR(outgoing_buffer);
 	header_ser = outgoing_buffer;
 	header_ser_pa = virt_to_phys(header_ser);
 
Signature · 1 line
2.51.0
#3 lore raw

PATCH 2/2 liveupdate: luo_session: Fix use after free in luo_session_deserialize()

In reply to Dan Carpenter

The debug output frees "session" but it was freed on the previous line. Move the free after the printk().

Fixes 7eeeec7e1690 ("liveupdate: luo_session: add sessions support")
---
 kernel/liveupdate/luo_session.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/liveupdate/luo_session.c +1 -1
index a572bf689712..b86d45c9dcbd 100644
@@ -553,9 +553,9 @@ int luo_session_deserialize(void)
 
 		err = luo_session_insert(sh, session);
 		if (err) {
-			luo_session_free(session);
 			pr_warn("Failed to insert session [%s] %pe\n",
 				session->name, ERR_PTR(err));
+			luo_session_free(session);
 			return err;
 		}
 
Signature · 1 line
2.51.0
maintainer
#2 lore raw

Re: [PATCH 1/2] liveupdate: luo_session: Fix uninitialized variable in luo_session_setup_outgoing()

In reply to Dan Carpenter
Quoted 15 lines · Dan Carpenter

The "header_ser" variable is uninitialized. The "outgoing_buffer" variable was intended here, so use that instead.

Fixes 7eeeec7e1690 ("liveupdate: luo_session: add sessions support")
---
 kernel/liveupdate/luo_session.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/liveupdate/luo_session.c +0 -0
index cf5c83b272e7..a572bf689712 100644

kernel/liveupdate/luo_session.c int __init luo_session_setup_outgoing(void *fdt_out) · line 452

Quoted 7 lines
kernel/liveupdate/luo_session.c +1 -1
@@ -447,7 +447,7 @@ int __init luo_session_setup_outgoing(void *fdt_out)
 
        outgoing_buffer = kho_alloc_preserve(LUO_SESSION_PGCNT << PAGE_SHIFT);
        if (IS_ERR(outgoing_buffer))
-               return PTR_ERR(header_ser);
+               return PTR_ERR(outgoing_buffer);
        header_ser = outgoing_buffer;
        header_ser_pa = virt_to_phys(header_ser);

This is already fixed in LUOv8.

Thank you,
Pasha

Quoted 4 lines
kernel/liveupdate/luo_session.c +0 -1
--

2.51.0

maintainer
#4 lore raw

Re: [PATCH 2/2] liveupdate: luo_session: Fix use after free in luo_session_deserialize()

In reply to Dan Carpenter
Quoted 15 lines · Dan Carpenter

The debug output frees "session" but it was freed on the previous line. Move the free after the printk().

Fixes 7eeeec7e1690 ("liveupdate: luo_session: add sessions support")
---
 kernel/liveupdate/luo_session.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/liveupdate/luo_session.c +0 -0
index a572bf689712..b86d45c9dcbd 100644

kernel/liveupdate/luo_session.c int luo_session_deserialize(void) · line 560

Quoted 9 lines
kernel/liveupdate/luo_session.c +1 -1
@@ -553,9 +553,9 @@ int luo_session_deserialize(void)
 
                err = luo_session_insert(sh, session);
                if (err) {
-                       luo_session_free(session);
                        pr_warn("Failed to insert session [%s] %pe\n",
                                session->name, ERR_PTR(err));
+                       luo_session_free(session);
                        return err;
                }

Andrew, could you please add this fix-up to "liveupdate: luo_session:
add sessions support"

Thank you,
Pasha

Quoted 4 lines
kernel/liveupdate/luo_session.c +0 -1
--

2.51.0

maintainer
#5 lore raw
In reply to Dan Carpenter
Quoted 2 lines · Dan Carpenter

Smatch detected these two bugs.

That's awesome, thank you for testing.

Pasha

Quoted 13 lines

Dan Carpenter (2):
liveupdate: luo_session: Fix uninitialized variable in
luo_session_setup_outgoing()
liveupdate: luo_session: Fix use after free in
luo_session_deserialize()

 kernel/liveupdate/luo_session.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--
2.51.0

maintainer
#6 lore raw
In reply to Dan Carpenter

(added Dan Carpenter)

Quoted 14 lines · Dan Carpenter

Smatch detected these two bugs.

Dan Carpenter (2):
liveupdate: luo_session: Fix uninitialized variable in
luo_session_setup_outgoing()
liveupdate: luo_session: Fix use after free in
luo_session_deserialize()

 kernel/liveupdate/luo_session.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.51.0
Signature · 2 lines
Sincerely yours,
Mike.
maintainer
#7 lore raw

Wrong thread, sorry for the noise

Quoted 21 lines · Mike Rapoport

(added Dan Carpenter)

Quoted 14 lines · Dan Carpenter

Smatch detected these two bugs.

Dan Carpenter (2):
liveupdate: luo_session: Fix uninitialized variable in
luo_session_setup_outgoing()
liveupdate: luo_session: Fix use after free in
luo_session_deserialize()

 kernel/liveupdate/luo_session.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.51.0
Signature · 2 lines
Sincerely yours,
Mike.
Signature · 2 lines
Sincerely yours,
Mike.