⬢ DragonFlyBSD Kernel Audit
DF-2524 / fix.diff
← back to finding ↓ download raw
--- a/sys/dev/disk/trm/trm.c
+++ b/sys/dev/disk/trm/trm.c
@@ -2352,7 +2352,20 @@
 		return;
 	}
 	pSRB = pDCB->pActiveSRB; 
-	/* bug pSRB=0 */
+	if (pSRB == NULL) {
+		/*
+		 * Spurious DISCONNECT/selection-timeout with no active
+		 * SRB (formerly: "bug pSRB=0").  Recover the bus instead
+		 * of dereferencing NULL.
+		 */
+		j = 400;
+		while (--j)
+			DELAY(1);
+		/* 1 msec */
+		trm_reg_write16((DO_CLRFIFO | DO_HWRESELECT),
+		    TRMREG_SCSI_CONTROL);
+		return;
+	}
 	target_id  = pSRB->pccb->ccb_h.target_id;
 	target_lun = pSRB->pccb->ccb_h.target_lun;
 	TRM_DPRINTF(":pDCB->pActiveSRB= %8x \n ",(u_int) pDCB->pActiveSRB);