Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

liveupdate: fix return value on session allocation failure

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.

Link: https://lore.kernel.org/20260415193738.515491-1-pasha.tatashin@soleen.com
Signed-off-by: Pasha Tatashin <pasha.tatashin@soleen.com>
Reviewed-by: Pratyush Yadav (Google) <pratyush@kernel.org>
Cc: David Matlack <dmatlack@google.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Pasha Tatashin and committed by
Andrew Morton
0562b572 60265506

+10 -5
+10 -5
kernel/liveupdate/luo_session.c
··· 514 514 { 515 515 struct luo_session_header *sh = &luo_session_global.incoming; 516 516 static bool is_deserialized; 517 - static int err; 517 + static int saved_err; 518 + int err; 518 519 519 520 /* If has been deserialized, always return the same error code */ 520 521 if (is_deserialized) 521 - return err; 522 + return saved_err; 522 523 523 524 is_deserialized = true; 524 525 if (!sh->active) ··· 548 547 pr_warn("Failed to allocate session [%.*s] during deserialization %pe\n", 549 548 (int)sizeof(sh->ser[i].name), 550 549 sh->ser[i].name, session); 551 - return PTR_ERR(session); 550 + err = PTR_ERR(session); 551 + goto save_err; 552 552 } 553 553 554 554 err = luo_session_insert(sh, session); ··· 557 555 pr_warn("Failed to insert session [%s] %pe\n", 558 556 session->name, ERR_PTR(err)); 559 557 luo_session_free(session); 560 - return err; 558 + goto save_err; 561 559 } 562 560 563 561 scoped_guard(mutex, &session->mutex) { ··· 567 565 if (err) { 568 566 pr_warn("Failed to deserialize files for session [%s] %pe\n", 569 567 session->name, ERR_PTR(err)); 570 - return err; 568 + goto save_err; 571 569 } 572 570 } 573 571 ··· 576 574 sh->ser = NULL; 577 575 578 576 return 0; 577 + save_err: 578 + saved_err = err; 579 + return err; 579 580 } 580 581 581 582 int luo_session_serialize(void)