DF-4240 / fix.diff
diff --git a/sys/dev/raid/dpt/dpt_scsi.c b/sys/dev/raid/dpt/dpt_scsi.c index ebc9e1a..91d5d27 100644 --- a/sys/dev/raid/dpt/dpt_scsi.c +++ b/sys/dev/raid/dpt/dpt_scsi.c @@ -1311,6 +1311,14 @@ dpt_init(struct dpt_softc *dpt) dpt->irq = conf.IRQ; dpt->dma_channel = (8 - conf.DMA_channel) & 7; dpt->channels = conf.MAX_CHAN + 1; + /* MAX_CHAN is a controller-fed 3-bit field; sims[]/paths[]/hostid[] + * in the softc are sized MAX_CHANNELS. Clamp before dpt_attach() + * walks the channel count. */ + if (dpt->channels > MAX_CHANNELS) { + kprintf("dpt%d: controller reported %d channels; clamping to %d\n", + dpt->unit, dpt->channels, MAX_CHANNELS); + dpt->channels = MAX_CHANNELS; + } dpt->state |= DPT_HA_OK; if (conf.SECOND) dpt->primary = FALSE; |