[PATCH] sgiioc4: check for no hwifs available
[sfrench/cifs-2.6.git] / drivers / ide / pci / sgiioc4.c
index af526b671c4e1f7ee0d9b274b5f2d90603fe7637..4ee597d087978c3e64c397849fccab1abeeb36cf 100644 (file)
@@ -622,12 +622,18 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t * d)
        ide_hwif_t *hwif;
        int h;
 
+       /*
+        * Find an empty HWIF; if none available, return -ENOMEM.
+        */
        for (h = 0; h < MAX_HWIFS; ++h) {
                hwif = &ide_hwifs[h];
-               /* Find an empty HWIF */
                if (hwif->chipset == ide_unknown)
                        break;
        }
+       if (h == MAX_HWIFS) {
+               printk(KERN_ERR "%s: too many IDE interfaces, no room in table\n", d->name);
+               return -ENOMEM;
+       }
 
        /*  Get the CmdBlk and CtrlBlk Base Registers */
        base = pci_resource_start(dev, 0) + IOC4_CMD_OFFSET;