diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index d9f06fbfa0bf8fd56051d5f1bd2252fdc52377f8..628c14150d49fe7019fd9a1c0921427ebe9d523f 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c @@ -439,8 +439,14 @@ static int msix_capability_init(struct pci_dev *dev, for (i = 0; i < nvec; i++) { entry = alloc_msi_entry(dev); - if (!entry) - break; + if (!entry) { + if (!i) + iounmap(base); + else + msi_free_irqs(dev); + /* No enough memory. Don't try again */ + return -ENOMEM; + } j = entries[i].entry; entry->msi_attrib.is_msix = 1;