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@intel.com> Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Reviewed-by: Conor Dooley <conor.dooley@microchip.com> Link: https://lore.kernel.org/r/20220920200037.6727-1-palmer@rivosinc.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com> Stable-dep-of: 130aee3fd998 ("riscv: Avoid enabling interrupts in die()") Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
030b1c4217
commit
f9fdb3e7b0
@@ -31,6 +31,7 @@ void die(struct pt_regs *regs, const char *str)
|
|||||||
{
|
{
|
||||||
static int die_counter;
|
static int die_counter;
|
||||||
int ret;
|
int ret;
|
||||||
|
long cause;
|
||||||
|
|
||||||
oops_enter();
|
oops_enter();
|
||||||
|
|
||||||
@@ -40,11 +41,13 @@ void die(struct pt_regs *regs, const char *str)
|
|||||||
|
|
||||||
pr_emerg("%s [#%d]\n", str, ++die_counter);
|
pr_emerg("%s [#%d]\n", str, ++die_counter);
|
||||||
print_modules();
|
print_modules();
|
||||||
|
if (regs)
|
||||||
show_regs(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);
|
crash_kexec(regs);
|
||||||
|
|
||||||
bust_spinlocks(0);
|
bust_spinlocks(0);
|
||||||
|
Reference in New Issue
Block a user