⬢ DragonFlyBSD Kernel Audit
DF-3893 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/dev/raid/mps/mps_sas.c b/sys/dev/raid/mps/mps_sas.c
index 1111111..2222222 100644
--- a/sys/dev/raid/mps/mps_sas.c
+++ b/sys/dev/raid/mps/mps_sas.c
@@ -2816,6 +2816,15 @@ mpssas_resetdev_complete(struct mps_softc *sc, struct mps_command *tm)
 		ccb->ccb_h.status = CAM_REQ_CMP_ERR;
 		goto bailout;
 	}
 
+	if (resp == NULL) {
+		/* DF-3893: completion via mpssas_complete_all_commands()
+		 * during a Diag Reset arrives with a NULL reply; do not
+		 * dereference it.  Same cleanup as the sibling handlers
+		 * (cf. mpssas_target_reset_complete, mps_sas.c:1246-1259).
+		 */
+		ccb->ccb_h.status = CAM_SCSI_BUS_RESET;
+		goto bailout;
+	}
+
 	kprintf("%s: IOCStatus = 0x%x ResponseCode = 0x%x\n", __func__,
 	    resp->IOCStatus, resp->ResponseCode);
 
*** With DF-3894's fix applied, bailout frees via the balanced
*** mpssas_alloc_tm/mpssas_free_tm pair; standalone, this guard merely
*** prevents the NULL deref on the existing (mis-pooled) path.