From: Dan Carpenter <error27@gmail.com>
To: oe-kbuild@lists.linux.dev, Youling Tang <tangyouling@loongson.cn>
Cc: lkp@intel.com, oe-kbuild-all@lists.linux.dev,
linux-kernel@vger.kernel.org, Huacai Chen <chenhuacai@kernel.org>
Subject: arch/loongarch/kernel/traps.c:250 die() warn: variable dereferenced before check 'regs' (see line 244)
Date: Tue, 15 Nov 2022 09:37:37 +0300 [thread overview]
Message-ID: <202211150324.eLx8WYhx-lkp@intel.com> (raw)
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
reply other threads:[~2022-11-15 6:37 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202211150324.eLx8WYhx-lkp@intel.com \
--to=error27@gmail.com \
--cc=chenhuacai@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=oe-kbuild-all@lists.linux.dev \
--cc=oe-kbuild@lists.linux.dev \
--cc=tangyouling@loongson.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®