mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* arch/loongarch/kernel/traps.c:250 die() warn: variable dereferenced before check 'regs' (see line 244)
@ 2022-11-15  6:37 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2022-11-15  6:37 UTC (permalink / raw)
  To: oe-kbuild, Youling Tang; +Cc: lkp, oe-kbuild-all, linux-kernel, Huacai Chen

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   094226ad94f471a9f19e8f8e7140a09c2625abaa
commit: 4e62d1d86585e1b62b4f96ee586881dd45a443dc LoongArch: Add kdump support
config: loongarch-randconfig-m031-20221114
compiler: loongarch64-linux-gcc (GCC) 12.1.0

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>

New smatch warnings:
arch/loongarch/kernel/traps.c:250 die() warn: variable dereferenced before check 'regs' (see line 244)

vim +/regs +250 arch/loongarch/kernel/traps.c

0603839b18f4fb Huacai Chen  2022-05-31  228  void __noreturn die(const char *str, struct pt_regs *regs)
0603839b18f4fb Huacai Chen  2022-05-31  229  {
0603839b18f4fb Huacai Chen  2022-05-31  230  	static int die_counter;
0603839b18f4fb Huacai Chen  2022-05-31  231  	int sig = SIGSEGV;
0603839b18f4fb Huacai Chen  2022-05-31  232  
0603839b18f4fb Huacai Chen  2022-05-31  233  	oops_enter();
0603839b18f4fb Huacai Chen  2022-05-31  234  
0603839b18f4fb Huacai Chen  2022-05-31  235  	if (notify_die(DIE_OOPS, str, regs, 0, current->thread.trap_nr,
0603839b18f4fb Huacai Chen  2022-05-31  236  		       SIGSEGV) == NOTIFY_STOP)
0603839b18f4fb Huacai Chen  2022-05-31  237  		sig = 0;
0603839b18f4fb Huacai Chen  2022-05-31  238  
0603839b18f4fb Huacai Chen  2022-05-31  239  	console_verbose();
0603839b18f4fb Huacai Chen  2022-05-31  240  	raw_spin_lock_irq(&die_lock);
0603839b18f4fb Huacai Chen  2022-05-31  241  	bust_spinlocks(1);
0603839b18f4fb Huacai Chen  2022-05-31  242  
0603839b18f4fb Huacai Chen  2022-05-31  243  	printk("%s[#%d]:\n", str, ++die_counter);
0603839b18f4fb Huacai Chen  2022-05-31 @244  	show_registers(regs);
                                                               ^^^^
Dereferenced without checking.

0603839b18f4fb Huacai Chen  2022-05-31  245  	add_taint(TAINT_DIE, LOCKDEP_NOW_UNRELIABLE);
0603839b18f4fb Huacai Chen  2022-05-31  246  	raw_spin_unlock_irq(&die_lock);
0603839b18f4fb Huacai Chen  2022-05-31  247  
0603839b18f4fb Huacai Chen  2022-05-31  248  	oops_exit();
0603839b18f4fb Huacai Chen  2022-05-31  249  
4e62d1d86585e1 Youling Tang 2022-10-12 @250  	if (regs && kexec_should_crash(current))
                                                    ^^^^
Too late.

4e62d1d86585e1 Youling Tang 2022-10-12  251  		crash_kexec(regs);
4e62d1d86585e1 Youling Tang 2022-10-12  252  
0603839b18f4fb Huacai Chen  2022-05-31  253  	if (in_interrupt())
0603839b18f4fb Huacai Chen  2022-05-31  254  		panic("Fatal exception in interrupt");
0603839b18f4fb Huacai Chen  2022-05-31  255  
0603839b18f4fb Huacai Chen  2022-05-31  256  	if (panic_on_oops)
0603839b18f4fb Huacai Chen  2022-05-31  257  		panic("Fatal exception");
0603839b18f4fb Huacai Chen  2022-05-31  258  
0603839b18f4fb Huacai Chen  2022-05-31  259  	make_task_dead(sig);
0603839b18f4fb Huacai Chen  2022-05-31  260  }

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-11-15  6:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-15  6:37 arch/loongarch/kernel/traps.c:250 die() warn: variable dereferenced before check 'regs' (see line 244) Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®