Skip to content

Commit a15df53

Browse files
johnpgarrymartinkpetersen
authored andcommitted
scsi: scsi_debug: Drop scsi_debug_target_reset() NULL pointer checks
The checks for SCSI cmnd, SCSI device, and SCSI host are unnecessary, so drop them. Likewise, drop the NULL check for sdbg_host. The only caller is scsi_try_target_reset() -> eh_target_reset_handler(), and there those pointers cannot be NULL. Signed-off-by: John Garry <john.g.garry@oracle.com> Acked-by: Douglas Gilbert <dgilbert@interlog.com> Link: https://lore.kernel.org/r/20230313093114.1498305-6-john.g.garry@oracle.com Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent a19226f commit a15df53

1 file changed

Lines changed: 10 additions & 21 deletions

File tree

drivers/scsi/scsi_debug.c

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5387,37 +5387,26 @@ static int scsi_debug_device_reset(struct scsi_cmnd *SCpnt)
53875387

53885388
static int scsi_debug_target_reset(struct scsi_cmnd *SCpnt)
53895389
{
5390-
struct sdebug_host_info *sdbg_host;
5390+
struct scsi_device *sdp = SCpnt->device;
5391+
struct sdebug_host_info *sdbg_host = shost_to_sdebug_host(sdp->host);
53915392
struct sdebug_dev_info *devip;
5392-
struct scsi_device *sdp;
5393-
struct Scsi_Host *hp;
53945393
int k = 0;
53955394

53965395
++num_target_resets;
5397-
if (!SCpnt)
5398-
goto lie;
5399-
sdp = SCpnt->device;
5400-
if (!sdp)
5401-
goto lie;
54025396
if (SDEBUG_OPT_ALL_NOISE & sdebug_opts)
54035397
sdev_printk(KERN_INFO, sdp, "%s\n", __func__);
5404-
hp = sdp->host;
5405-
if (!hp)
5406-
goto lie;
5407-
sdbg_host = shost_to_sdebug_host(hp);
5408-
if (sdbg_host) {
5409-
list_for_each_entry(devip,
5410-
&sdbg_host->dev_info_list,
5411-
dev_list)
5412-
if (devip->target == sdp->id) {
5413-
set_bit(SDEBUG_UA_BUS_RESET, devip->uas_bm);
5414-
++k;
5415-
}
5398+
5399+
list_for_each_entry(devip, &sdbg_host->dev_info_list, dev_list) {
5400+
if (devip->target == sdp->id) {
5401+
set_bit(SDEBUG_UA_BUS_RESET, devip->uas_bm);
5402+
++k;
5403+
}
54165404
}
5405+
54175406
if (SDEBUG_OPT_RESET_NOISE & sdebug_opts)
54185407
sdev_printk(KERN_INFO, sdp,
54195408
"%s: %d device(s) found in target\n", __func__, k);
5420-
lie:
5409+
54215410
return SUCCESS;
54225411
}
54235412

0 commit comments

Comments
 (0)