spi: topcliff-pch: Properly unregister platform devices on probe() error paths
authorAxel Lin <axel.lin@ingics.com>
Mon, 24 Mar 2014 07:46:55 +0000 (15:46 +0800)
committerMark Brown <broonie@linaro.org>
Mon, 24 Mar 2014 10:57:02 +0000 (10:57 +0000)
Ensure all registered platform devices are unregistered on probe() error paths.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
drivers/spi/spi-topcliff-pch.c

index dc5d2d489953ce66642076bdd47b5e0a102a07a7..372811aa5fb23673ffa1e5c1c823c9d98b800b57 100644 (file)
@@ -1568,8 +1568,7 @@ static struct platform_driver pch_spi_pd_driver = {
        .resume = pch_spi_pd_resume
 };
 
-static int pch_spi_probe(struct pci_dev *pdev,
-                                  const struct pci_device_id *id)
+static int pch_spi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 {
        struct pch_spi_board_data *board_dat;
        struct platform_device *pd_dev = NULL;
@@ -1639,6 +1638,8 @@ static int pch_spi_probe(struct pci_dev *pdev,
        return 0;
 
 err_platform_device:
+       while (--i >= 0)
+               platform_device_unregister(pd_dev_save->pd_save[i]);
        pci_disable_device(pdev);
 pci_enable_device:
        pci_release_regions(pdev);