From: Hannes Reinecke Date: Mon, 23 Oct 2023 07:30:14 +0000 (+0200) Subject: scsi: aic79xx: Fix up NULL command in ahd_done() X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=c7f4c5dec651090f99b0d2b946e028e1ea90d22a;p=linux.git scsi: aic79xx: Fix up NULL command in ahd_done() Found by smatch. Fixes: c67e63800446 ("scsi: aic79xx: Do not reference SCSI command when resetting device") Reported-by: Dan Carpenter Signed-off-by: Hannes Reinecke Link: https://lore.kernel.org/r/20231023073014.21438-1-hare@suse.de Signed-off-by: Martin K. Petersen --- diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c index b3075a022d99a..4202059815a0b 100644 --- a/drivers/scsi/aic7xxx/aic79xx_osm.c +++ b/drivers/scsi/aic7xxx/aic79xx_osm.c @@ -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