[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202211150324.eLx8WYhx-lkp@intel.com>
Date: Tue, 15 Nov 2022 09:37:37 +0300
From: Dan Carpenter <error27@...il.com>
To: oe-kbuild@...ts.linux.dev, Youling Tang <tangyouling@...ngson.cn>
Cc: lkp@...el.com, oe-kbuild-all@...ts.linux.dev,
linux-kernel@...r.kernel.org, Huacai Chen <chenhuacai@...nel.org>
Subject: arch/loongarch/kernel/traps.c:250 die() warn: variable dereferenced
before check 'regs' (see line 244)
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@...el.com>
| Reported-by: Dan Carpenter <error27@...il.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
Powered by blists - more mailing lists