⬢ DragonFlyBSD Kernel Audit
DF-3894 / 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
@@ -2762,7 +2762,6 @@ mpssas_action_resetdev(struct mpssas_softc *sassc, union ccb *ccb)
 	mps_dprint(sassc->sc, MPS_TRACE, __func__);
 	KKASSERT(lockowned(&sassc->sc->mps_lock));
 
 	sc = sassc->sc;
-	tm = mps_alloc_command(sc);
+	/* DF-3894: allocate from the high-priority pool via the TM
+	 * helper so that mpssas_resetdev_complete's mpssas_free_tm()
+	 * (high-priority free + tm_count decrement) is balanced and the
+	 * simq is frozen while the TM is in flight. */
+	tm = mpssas_alloc_tm(sc);
 	if (tm == NULL) {
 		mps_printf(sc, "command alloc failure in mpssas_action_resetdev\n");
 		ccb->ccb_h.status = CAM_RESRC_UNAVAIL;
@@ -2771,6 +2770,7 @@ mpssas_action_resetdev(struct mpssas_softc *sassc, union ccb *ccb)
 
 	targ = &sassc->targets[ccb->ccb_h.target_id];
 	req = (MPI2_SCSI_TASK_MANAGE_REQUEST *)tm->cm_req;
+	memset(req, 0, sizeof(*req));	/* only TM sender that reused stale frames */
 	req->DevHandle = targ->handle;
 	req->Function = MPI2_FUNCTION_SCSI_TASK_MGMT;
 	req->TaskType = MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET;