oe-kbuild.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: oe-kbuild@lists.linux.dev
Cc: lkp@intel.com
Subject: arch/loongarch/kernel/traps.c:93:39: warning: Null pointer dereference: regs [ctunullpointer]
Date: Mon, 5 Dec 2022 18:52:01 +0800	[thread overview]
Message-ID: <202212051821.pYErx34b-lkp@intel.com> (raw)

:::::: 
:::::: Manual check reason: "low confidence static check warning: arch/loongarch/kernel/traps.c:93:39: warning: Null pointer dereference: regs [ctunullpointer]"
:::::: 

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: Youling Tang <tangyouling@loongson.cn>
CC: Huacai Chen <chenhuacai@kernel.org>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   76dcd734eca23168cb008912c0f69ff408905235
commit: 4e62d1d86585e1b62b4f96ee586881dd45a443dc LoongArch: Add kdump support
date:   8 weeks ago
:::::: branch date: 12 hours ago
:::::: commit date: 8 weeks ago
compiler: loongarch64-linux-gcc (GCC) 12.1.0
reproduce (cppcheck warning):
        # apt-get install cppcheck
        git checkout 4e62d1d86585e1b62b4f96ee586881dd45a443dc
        cppcheck --quiet --enable=style,performance,portability --template=gcc FILE

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


cppcheck possible warnings: (new ones prefixed by >>, may not real problems)

>> arch/loongarch/kernel/traps.c:93:39: warning: Null pointer dereference: regs [ctunullpointer]
    unsigned long *sp = (unsigned long *)regs->regs[3];
                                         ^
   arch/loongarch/kernel/traps.c:250:6: note: Assuming that condition 'regs' is not redundant
   
        ^
   arch/loongarch/kernel/traps.c:244:17: note: Calling function 'show_registers', 1st argument 'regs' value is 0
   
                   ^
   arch/loongarch/kernel/traps.c:221:17: note: Calling function show_stacktrace, 2nd argument is null
    show_stacktrace(current, regs, KERN_DEFAULT, user_mode(regs));
                   ^
   arch/loongarch/kernel/traps.c:93:39: note: Dereferencing argument regs that is null
    unsigned long *sp = (unsigned long *)regs->regs[3];
                                         ^

vim +93 arch/loongarch/kernel/traps.c

0603839b18f4fb Huacai Chen 2022-05-31   86  
0603839b18f4fb Huacai Chen 2022-05-31   87  static void show_stacktrace(struct task_struct *task,
0603839b18f4fb Huacai Chen 2022-05-31   88  	const struct pt_regs *regs, const char *loglvl, bool user)
0603839b18f4fb Huacai Chen 2022-05-31   89  {
0603839b18f4fb Huacai Chen 2022-05-31   90  	int i;
0603839b18f4fb Huacai Chen 2022-05-31   91  	const int field = 2 * sizeof(unsigned long);
0603839b18f4fb Huacai Chen 2022-05-31   92  	unsigned long stackdata;
0603839b18f4fb Huacai Chen 2022-05-31  @93  	unsigned long *sp = (unsigned long *)regs->regs[3];
0603839b18f4fb Huacai Chen 2022-05-31   94  
0603839b18f4fb Huacai Chen 2022-05-31   95  	printk("%sStack :", loglvl);
0603839b18f4fb Huacai Chen 2022-05-31   96  	i = 0;
0603839b18f4fb Huacai Chen 2022-05-31   97  	while ((unsigned long) sp & (PAGE_SIZE - 1)) {
0603839b18f4fb Huacai Chen 2022-05-31   98  		if (i && ((i % (64 / field)) == 0)) {
0603839b18f4fb Huacai Chen 2022-05-31   99  			pr_cont("\n");
0603839b18f4fb Huacai Chen 2022-05-31  100  			printk("%s       ", loglvl);
0603839b18f4fb Huacai Chen 2022-05-31  101  		}
0603839b18f4fb Huacai Chen 2022-05-31  102  		if (i > 39) {
0603839b18f4fb Huacai Chen 2022-05-31  103  			pr_cont(" ...");
0603839b18f4fb Huacai Chen 2022-05-31  104  			break;
0603839b18f4fb Huacai Chen 2022-05-31  105  		}
0603839b18f4fb Huacai Chen 2022-05-31  106  
0603839b18f4fb Huacai Chen 2022-05-31  107  		if (__get_addr(&stackdata, sp++, user)) {
0603839b18f4fb Huacai Chen 2022-05-31  108  			pr_cont(" (Bad stack address)");
0603839b18f4fb Huacai Chen 2022-05-31  109  			break;
0603839b18f4fb Huacai Chen 2022-05-31  110  		}
0603839b18f4fb Huacai Chen 2022-05-31  111  
0603839b18f4fb Huacai Chen 2022-05-31  112  		pr_cont(" %0*lx", field, stackdata);
0603839b18f4fb Huacai Chen 2022-05-31  113  		i++;
0603839b18f4fb Huacai Chen 2022-05-31  114  	}
0603839b18f4fb Huacai Chen 2022-05-31  115  	pr_cont("\n");
0603839b18f4fb Huacai Chen 2022-05-31  116  	show_backtrace(task, regs, loglvl, user);
0603839b18f4fb Huacai Chen 2022-05-31  117  }
0603839b18f4fb Huacai Chen 2022-05-31  118  

:::::: The code at line 93 was first introduced by commit
:::::: 0603839b18f4fb3bffa82515efcf5b02084505ef LoongArch: Add exception/interrupt handling

:::::: TO: Huacai Chen <chenhuacai@loongson.cn>
:::::: CC: Huacai Chen <chenhuacai@loongson.cn>

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

             reply	other threads:[~2022-12-05 10:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-05 10:52 kernel test robot [this message]
2023-01-29 16:25 arch/loongarch/kernel/traps.c:93:39: warning: Null pointer dereference: regs [ctunullpointer] kernel test robot

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=202212051821.pYErx34b-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=oe-kbuild@lists.linux.dev \
    /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;
as well as URLs for NNTP newsgroup(s).