Skip to contentSkip to conversation

aic79xx: fix up NULL command in ahd_done()

PATCH Applied Hannes Reinecke 3 participants 4 messages Oct 23, 2023 – Oct 30, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 aic79xx: fix up NULL command in ahd_done()

Found by smatch.

Fixes c67e63800446 ("scsi: aic79xx: Do not reference SCSI command when resetting device")
---
 drivers/scsi/aic7xxx/aic79xx_osm.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/scsi/aic7xxx/aic79xx_osm.c +3 -2
index b3075a022d99..77c91a405d20 100644
@@ -1834,7 +1834,7 @@ 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 +1868,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
Signature · 1 line
2.35.3
#1 lore raw

drivers/scsi/aic7xxx/aic79xx_osm.c ahd_done(struct ahd_softc *ahd, struct scb *scb) · line 1837

Quoted 7 lines · Hannes Reinecke

+++ b/drivers/scsi/aic7xxx/aic79xx_osm.c

drivers/scsi/aic7xxx/aic79xx_osm.c +1 -1
@@ -1834,7 +1834,7 @@ 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) {

Please avoid the overly long line here.

Otherwise looks good.