Clamp ahci max irq's to AHCI_MAX_IRQS

This prevents the possiblity of any overruns on the statically allocated
struct irqs field.

Differential Revision:	D838
MFC after:	2 weeks
X-MFC-With:	r276012
Sponsored by:	Multiplay
This commit is contained in:
smh 2014-12-21 16:15:29 +00:00
parent 527999674a
commit 1bbb36e3f1

View File

@ -356,6 +356,14 @@ ahci_setup_interrupt(device_t dev)
device_printf(dev, "Falling back to one MSI\n");
ctlr->numirqs = 1;
}
/* Ensure we don't overrun irqs. */
if (ctlr->numirqs > AHCI_MAX_IRQS) {
device_printf(dev, "Too many irqs %d > %d (clamping)\n",
ctlr->numirqs, AHCI_MAX_IRQS);
ctlr->numirqs = AHCI_MAX_IRQS;
}
/* Allocate all IRQs. */
for (i = 0; i < ctlr->numirqs; i++) {
ctlr->irqs[i].ctlr = ctlr;