Re: [PATCH v2 2/6] scsi:scsi_debug: Add interface to manage single device's error inject

From: Dan Carpenter
Date: Thu May 11 2023 - 06:57:22 EST


Hi Wenchao,

kernel test robot noticed the following build warnings:

https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Wenchao-Hao/scsi-scsi_debug-create-scsi_debug-directory-in-the-debugfs-filesystem/20230427-201534
base: https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next
patch link: https://lore.kernel.org/r/20230428013320.347050-3-haowenchao2%40huawei.com
patch subject: [PATCH v2 2/6] scsi:scsi_debug: Add interface to manage single device's error inject
config: mips-randconfig-m041-20230509 (https://download.01.org/0day-ci/archive/20230511/202305110949.SGOuSCr6-lkp@xxxxxxxxx/config)
compiler: mips-linux-gcc (GCC) 12.1.0

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Reported-by: Dan Carpenter <error27@xxxxxxxxx>
| Link: https://lore.kernel.org/r/202305110949.SGOuSCr6-lkp@xxxxxxxxx/

smatch warnings:
drivers/scsi/scsi_debug.c:5359 scsi_debug_slave_destroy() warn: variable dereferenced before check 'devip' (see line 5358)

vim +/devip +5359 drivers/scsi/scsi_debug.c

8dea0d02f8bb71 FUJITA Tomonori 2008-03-30 5349 static void scsi_debug_slave_destroy(struct scsi_device *sdp)
8dea0d02f8bb71 FUJITA Tomonori 2008-03-30 5350 {
8dea0d02f8bb71 FUJITA Tomonori 2008-03-30 5351 struct sdebug_dev_info *devip =
8dea0d02f8bb71 FUJITA Tomonori 2008-03-30 5352 (struct sdebug_dev_info *)sdp->hostdata;
a34c4e98367965 FUJITA Tomonori 2008-03-25 5353
773642d95b8220 Douglas Gilbert 2016-04-25 5354 if (sdebug_verbose)
c1287970f4847a Tomas Winkler 2015-07-28 5355 pr_info("slave_destroy <%u %u %u %llu>\n",
8dea0d02f8bb71 FUJITA Tomonori 2008-03-30 5356 sdp->host->host_no, sdp->channel, sdp->id, sdp->lun);
46ab9018f5b07d Wenchao Hao 2023-04-28 5357
46ab9018f5b07d Wenchao Hao 2023-04-28 @5358 debugfs_remove(devip->debugfs_entry);
^^^^^^^^^^^^^^^^^^^^
Dereference

8dea0d02f8bb71 FUJITA Tomonori 2008-03-30 @5359 if (devip) {
^^^^^
Checked too late.

25985edcedea63 Lucas De Marchi 2011-03-30 5360 /* make this slot available for re-use */
c2248fc974df7b Douglas Gilbert 2014-11-24 5361 devip->used = false;
8dea0d02f8bb71 FUJITA Tomonori 2008-03-30 5362 sdp->hostdata = NULL;
8dea0d02f8bb71 FUJITA Tomonori 2008-03-30 5363 }
8dea0d02f8bb71 FUJITA Tomonori 2008-03-30 5364 }

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