Patch "RISC-V: Avoid dereferening NULL regs in die()" has been added to the 5.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    RISC-V: Avoid dereferening NULL regs in die()

to the 5.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     risc-v-avoid-dereferening-null-regs-in-die.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit f0d5977c98155a0bed9f1a9093ca9a7e9f2d0f0e
Author: Palmer Dabbelt <palmer@xxxxxxxxxxxx>
Date:   Tue Sep 20 13:00:37 2022 -0700

    RISC-V: Avoid dereferening NULL regs in die()
    
    [ Upstream commit f2913d006fcdb61719635e093d1b5dd0dafecac7 ]
    
    I don't think we can actually die() without a regs pointer, but the
    compiler was warning about a NULL check after a dereference.  It seems
    prudent to just avoid the possibly-NULL dereference, given that when
    die()ing the system is already toast so who knows how we got there.
    
    Reported-by: kernel test robot <lkp@xxxxxxxxx>
    Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
    Reviewed-by: Conor Dooley <conor.dooley@xxxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20220920200037.6727-1-palmer@xxxxxxxxxxxx
    Signed-off-by: Palmer Dabbelt <palmer@xxxxxxxxxxxx>
    Stable-dep-of: 130aee3fd998 ("riscv: Avoid enabling interrupts in die()")
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c
index 23fe03ca7ec7b..bc6b30f3add83 100644
--- a/arch/riscv/kernel/traps.c
+++ b/arch/riscv/kernel/traps.c
@@ -31,6 +31,7 @@ void die(struct pt_regs *regs, const char *str)
 {
 	static int die_counter;
 	int ret;
+	long cause;
 
 	oops_enter();
 
@@ -40,11 +41,13 @@ void die(struct pt_regs *regs, const char *str)
 
 	pr_emerg("%s [#%d]\n", str, ++die_counter);
 	print_modules();
-	show_regs(regs);
+	if (regs)
+		show_regs(regs);
 
-	ret = notify_die(DIE_OOPS, str, regs, 0, regs->cause, SIGSEGV);
+	cause = regs ? regs->cause : -1;
+	ret = notify_die(DIE_OOPS, str, regs, 0, cause, SIGSEGV);
 
-	if (regs && kexec_should_crash(current))
+	if (kexec_should_crash(current))
 		crash_kexec(regs);
 
 	bust_spinlocks(0);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux