scsi: scsi_debug: Drop scsi_debug_target_reset() NULL pointer checks
authorJohn Garry <john.g.garry@oracle.com>
Mon, 13 Mar 2023 09:31:08 +0000 (09:31 +0000)
committerMartin K. Petersen <martin.petersen@oracle.com>
Fri, 17 Mar 2023 03:25:37 +0000 (23:25 -0400)
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>
drivers/scsi/scsi_debug.c

index 7b0e39d..f92a0da 100644 (file)
@@ -5387,37 +5387,26 @@ static int scsi_debug_device_reset(struct scsi_cmnd *SCpnt)
 
 static int scsi_debug_target_reset(struct scsi_cmnd *SCpnt)
 {
-       struct sdebug_host_info *sdbg_host;
+       struct scsi_device *sdp = SCpnt->device;
+       struct sdebug_host_info *sdbg_host = shost_to_sdebug_host(sdp->host);
        struct sdebug_dev_info *devip;
-       struct scsi_device *sdp;
-       struct Scsi_Host *hp;
        int k = 0;
 
        ++num_target_resets;
-       if (!SCpnt)
-               goto lie;
-       sdp = SCpnt->device;
-       if (!sdp)
-               goto lie;
        if (SDEBUG_OPT_ALL_NOISE & sdebug_opts)
                sdev_printk(KERN_INFO, sdp, "%s\n", __func__);
-       hp = sdp->host;
-       if (!hp)
-               goto lie;
-       sdbg_host = shost_to_sdebug_host(hp);
-       if (sdbg_host) {
-               list_for_each_entry(devip,
-                                   &sdbg_host->dev_info_list,
-                                   dev_list)
-                       if (devip->target == sdp->id) {
-                               set_bit(SDEBUG_UA_BUS_RESET, devip->uas_bm);
-                               ++k;
-                       }
+
+       list_for_each_entry(devip, &sdbg_host->dev_info_list, dev_list) {
+               if (devip->target == sdp->id) {
+                       set_bit(SDEBUG_UA_BUS_RESET, devip->uas_bm);
+                       ++k;
+               }
        }
+
        if (SDEBUG_OPT_RESET_NOISE & sdebug_opts)
                sdev_printk(KERN_INFO, sdp,
                            "%s: %d device(s) found in target\n", __func__, k);
-lie:
+
        return SUCCESS;
 }