scsi: aic79xx: Fix up NULL command in ahd_done()
authorHannes Reinecke <hare@suse.de>
Mon, 23 Oct 2023 07:30:14 +0000 (09:30 +0200)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 25 Oct 2023 02:38:34 +0000 (22:38 -0400)
Found by smatch.

Fixes: c67e63800446 ("scsi: aic79xx: Do not reference SCSI command when resetting device")
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Link: https://lore.kernel.org/r/20231023073014.21438-1-hare@suse.de
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/aic7xxx/aic79xx_osm.c

index b3075a022d99a481896a113023a04e1af5c64f7e..4202059815a0beb5875ac14c3241b30978566c59 100644 (file)
@@ -1834,7 +1834,8 @@ ahd_done(struct ahd_softc *ahd, struct scb *scb)
                } else {
                        ahd_set_transaction_status(scb, CAM_REQ_CMP);
                }
-       } else if (ahd_get_transaction_status(scb) == CAM_SCSI_STATUS_ERROR) {
+       } else if (cmd &&
+                  ahd_get_transaction_status(scb) == CAM_SCSI_STATUS_ERROR) {
                ahd_linux_handle_scsi_status(ahd, cmd->device, scb);
        }
 
@@ -1868,7 +1869,8 @@ ahd_done(struct ahd_softc *ahd, struct scb *scb)
        }
 
        ahd_free_scb(ahd, scb);
-       ahd_linux_queue_cmd_complete(ahd, cmd);
+       if (cmd)
+               ahd_linux_queue_cmd_complete(ahd, cmd);
 }
 
 static void