Commit 9599f341 authored by Jay Fang's avatar Jay Fang Committed by Mark Brown

spi: dw-pci: free previously allocated IRQs if desc->setup() fails

Free previously allocated IRQs when return an error code of desc->setup()
which is not always successful. And simplify the code by adding a goto
label.

Fixes: 8f5c285f ("SPI: designware: pci: Switch over to MSI interrupts")
CC: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: default avatarJay Fang <f.fangjian@huawei.com>
Link: https://lore.kernel.org/r/1600132969-53037-1-git-send-email-f.fangjian@huawei.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 55ab8487
...@@ -127,18 +127,16 @@ static int spi_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -127,18 +127,16 @@ static int spi_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (desc->setup) { if (desc->setup) {
ret = desc->setup(dws); ret = desc->setup(dws);
if (ret) if (ret)
return ret; goto err_free_irq_vectors;
} }
} else { } else {
pci_free_irq_vectors(pdev); ret = -ENODEV;
return -ENODEV; goto err_free_irq_vectors;
} }
ret = dw_spi_add_host(&pdev->dev, dws); ret = dw_spi_add_host(&pdev->dev, dws);
if (ret) { if (ret)
pci_free_irq_vectors(pdev); goto err_free_irq_vectors;
return ret;
}
/* PCI hook and SPI hook use the same drv data */ /* PCI hook and SPI hook use the same drv data */
pci_set_drvdata(pdev, dws); pci_set_drvdata(pdev, dws);
...@@ -152,6 +150,10 @@ static int spi_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -152,6 +150,10 @@ static int spi_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
pm_runtime_allow(&pdev->dev); pm_runtime_allow(&pdev->dev);
return 0; return 0;
err_free_irq_vectors:
pci_free_irq_vectors(pdev);
return ret;
} }
static void spi_pci_remove(struct pci_dev *pdev) static void spi_pci_remove(struct pci_dev *pdev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment