spi: Insert the missing pci_dev_put()before return
authorYang Ruibin <11162571@vivo.com>
Thu, 29 Aug 2024 03:35:11 +0000 (11:35 +0800)
committerMark Brown <broonie@kernel.org>
Thu, 29 Aug 2024 12:02:04 +0000 (13:02 +0100)
Increase the reference count by calling pci_get_slot(), and remember to
decrement the reference count by calling pci_dev_put().

Signed-off-by: Yang Ruibin <11162571@vivo.com>
Link: https://patch.msgid.link/20240829033511.1917015-1-11162571@vivo.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-pxa2xx-pci.c

index 616d032f1a89a2c361daa47532f43a0093c0920a..d49d8fef4088a019f642f5a8d5209e149d722c9b 100644 (file)
@@ -145,8 +145,10 @@ static int lpss_spi_setup(struct pci_dev *dev, struct pxa2xx_spi_controller *c)
        c->num_chipselect = 1;
 
        ret = pxa2xx_spi_pci_clk_register(dev, ssp, 50000000);
-       if (ret)
+       if (ret) {
+               pci_dev_put(dma_dev);
                return ret;
+       }
 
        dma_dev = pci_get_slot(dev->bus, PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
        ret = devm_add_action_or_reset(&dev->dev, lpss_dma_put_device, dma_dev);
@@ -221,8 +223,10 @@ static int mrfld_spi_setup(struct pci_dev *dev, struct pxa2xx_spi_controller *c)
        }
 
        ret = pxa2xx_spi_pci_clk_register(dev, ssp, 25000000);
-       if (ret)
+       if (ret) {
+               pci_dev_put(dma_dev);
                return ret;
+       }
 
        dma_dev = pci_get_slot(dev->bus, PCI_DEVFN(21, 0));
        ret = devm_add_action_or_reset(&dev->dev, lpss_dma_put_device, dma_dev);