⬢ DragonFlyBSD Kernel Audit
DF-3962 / fix.diff
← back to finding ↓ download raw
--- a/sys/dev/raid/hptiop/hptiop.c	2026-09-17 06:16:59.056779292 +0000
+++ b/sys/dev/raid/hptiop/hptiop.c	2026-09-17 06:16:59.084778935 +0000
@@ -2244,9 +2244,20 @@ static void hptiop_disable_intr_mvfrey(s
 static void hptiop_reset_adapter(void *argv)
 {
 	struct hpt_iop_hba * hba = (struct hpt_iop_hba *)argv;
-	if (hptiop_send_sync_msg(hba, IOPMU_INBOUND_MSG0_RESET, 60000))
+
+	/*
+	 * Serialize with hptiop_pci_intr(): send_sync_msg() polls
+	 * iop_intr(), which would otherwise complete SRBs concurrently
+	 * with the hard interrupt handler (double free_srb / xpt_done).
+	 * Lock is recursive for the XPT_RESET_BUS path.
+	 */
+	hptiop_lock_adapter(hba);
+	if (hptiop_send_sync_msg(hba, IOPMU_INBOUND_MSG0_RESET, 60000)) {
+		hptiop_unlock_adapter(hba);
 		return;
+	}
 	hptiop_send_sync_msg(hba, IOPMU_INBOUND_MSG0_START_BACKGROUND_TASK, 5000);
+	hptiop_unlock_adapter(hba);
 }
 
 static void *hptiop_get_srb(struct hpt_iop_hba * hba)