⬢ DragonFlyBSD Kernel Audit
DF-2210 / fix.diff
← back to finding ↓ download raw
--- a/sys/dev/disk/nata/chipsets/ata-national.c
+++ b/sys/dev/disk/nata/chipsets/ata-national.c
@@ -74,8 +74,14 @@
 	    { 0x80921250, 0x80911140, 0x80911030 };
     int error;
 
-    ch->dma->alignment = 16;
-    ch->dma->max_iosize = 64 * DEV_BSIZE;
+    /* ch->dma is NULL when DMA allocation failed (ata-dma.c:153) or PCI
+     * busmastering is unavailable; the channel then runs PIO-only and
+     * setmode must not touch the DMA descriptors.  Guard like the Cyrix
+     * original (ata-cyrix.c:82 guards the same derefs). */
+    if (ch->dma) {
+	ch->dma->alignment = 16;
+	ch->dma->max_iosize = 64 * DEV_BSIZE;
+    }
 
     mode = ata_limit_mode(dev, mode, ATA_UDMA2);