[paulmck-rcu:dev.2023.08.22a 63/69] kernel/locking/locktorture.c:294:20-23: ERROR: t is NULL but dereferenced. (fwd)

From: Julia Lawall
Date: Thu Aug 31 2023 - 05:01:18 EST


Maybe a ! has been forgotton on line 290?

julia

---------- Forwarded message ----------
Date: Thu, 31 Aug 2023 10:46:56 +0800
From: kernel test robot <lkp@xxxxxxxxx>
To: oe-kbuild@xxxxxxxxxxxxxxx
Cc: lkp@xxxxxxxxx, Julia Lawall <julia.lawall@xxxxxxxx>
Subject: [paulmck-rcu:dev.2023.08.22a 63/69]
kernel/locking/locktorture.c:294:20-23: ERROR: t is NULL but dereferenced.

BCC: lkp@xxxxxxxxx
CC: oe-kbuild-all@xxxxxxxxxxxxxxx
CC: linux-kernel@xxxxxxxxxxxxxxx
TO: "Paul E. McKenney" <paulmck@xxxxxxxxxx>

tree: https://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git dev.2023.08.22a
head: 354957ec11dc80eac68c4b1e10c237d69adc1833
commit: 758918804e0d5216981df3cef99ffd7ba0842192 [63/69] locktorture: Add indication of task write-holding lock
:::::: branch date: 6 days ago
:::::: commit date: 7 days ago
config: i386-randconfig-053-20230831 (https://download.01.org/0day-ci/archive/20230831/202308311022.j7jKnIdL-lkp@xxxxxxxxx/config)
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
reproduce: (https://download.01.org/0day-ci/archive/20230831/202308311022.j7jKnIdL-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Reported-by: Julia Lawall <julia.lawall@xxxxxxxx>
| Closes: https://lore.kernel.org/r/202308311022.j7jKnIdL-lkp@xxxxxxxxx/

cocci warnings: (new ones prefixed by >>)
>> kernel/locking/locktorture.c:294:20-23: ERROR: t is NULL but dereferenced.
kernel/locking/locktorture.c:294:43-47: ERROR: t is NULL but dereferenced.

vim +294 kernel/locking/locktorture.c

bdd8d60bd4047a Paul E. McKenney 2023-08-23 284
94a8fb5e4673d7 Paul E. McKenney 2023-08-22 285 static int torture_spin_lock_dump(struct notifier_block *nb, unsigned long v, void *ptr)
94a8fb5e4673d7 Paul E. McKenney 2023-08-22 286 {
758918804e0d52 Paul E. McKenney 2023-08-23 287 struct task_struct *t = READ_ONCE(lock_is_write_held);
758918804e0d52 Paul E. McKenney 2023-08-23 288
94a8fb5e4673d7 Paul E. McKenney 2023-08-22 289 pr_alert("%s invoked: v=%lu, duration=%lu.\n", __func__, v, (unsigned long)ptr);
758918804e0d52 Paul E. McKenney 2023-08-23 290 if (t) {
758918804e0d52 Paul E. McKenney 2023-08-23 291 pr_alert("%s No task holding lock.\n", __func__);
758918804e0d52 Paul E. McKenney 2023-08-23 292 } else {
758918804e0d52 Paul E. McKenney 2023-08-23 293 pr_alert("%s Lock held by task %ps %d %*s\n",
758918804e0d52 Paul E. McKenney 2023-08-23 @294 __func__, t, t->pid, TASK_COMM_LEN, t->comm);
758918804e0d52 Paul E. McKenney 2023-08-23 295 sched_show_task(t);
758918804e0d52 Paul E. McKenney 2023-08-23 296 }
bdd8d60bd4047a Paul E. McKenney 2023-08-23 297 spinlock_dump(&torture_spinlock, true);
94a8fb5e4673d7 Paul E. McKenney 2023-08-22 298 return NOTIFY_OK;
94a8fb5e4673d7 Paul E. McKenney 2023-08-22 299 }
94a8fb5e4673d7 Paul E. McKenney 2023-08-22 300

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki