⬢ DragonFlyBSD Kernel Audit
DF-3803 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/dev/raid/mpr/mpr_sas.c b/sys/dev/raid/mpr/mpr_sas.c
index 1111111..2222222 100644
--- a/sys/dev/raid/mpr/mpr_sas.c
+++ b/sys/dev/raid/mpr/mpr_sas.c
@@ -3801,6 +3801,13 @@ mprsas_prepare_for_tm(struct mpr_softc *sc, struct mpr_command *tm,
 	union ccb *ccb;
 	path_id_t path_id;
 
+	/*
+	 * DF-3803: error recovery reuses the same tm (re-abort, LUN reset,
+	 * target reset escalations); release the previous ccb/path before
+	 * allocating a new one or they leak.
+	 */
+	if (tm->cm_ccb != NULL) {
+		xpt_free_path(tm->cm_ccb->ccb_h.path);
+		xpt_free_ccb(&tm->cm_ccb->ccb_h);
+		tm->cm_ccb = NULL;
+	}
 	ccb = xpt_alloc_ccb();
 	if (ccb) {
 		path_id = cam_sim_path(sc->sassc->sim);