DragonFlyBSD Kernel Audit
DF-1210 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/dev/disk/ahci/ahci.c b/sys/dev/disk/ahci/ahci.c
--- a/sys/dev/disk/ahci/ahci.c
+++ b/sys/dev/disk/ahci/ahci.c
@@ -2844,6 +2844,12 @@
 		    (cmd & AHCI_PREG_CMD_ST) == 0) {
 			err_slot = AHCI_PREG_CMD_CCS(
 						ahci_pread(ap, AHCI_PREG_CMD));
+			if (err_slot < 0 || err_slot >= ap->ap_sc->sc_ncmds) {
+				kprintf("%s: DHRS bad error slot %d\n",
+					PORTNAME(ap), err_slot);
+				err_slot = -1;
+				goto process_error;
+			}
 			ccb = &ap->ap_ccbs[err_slot];
 			kprintf("%s: DHRS tfd=%pb%i err_slot=%d cmd=%02x\n",
 				PORTNAME(ap), AHCI_PFMT_TFD_STS, tfd,