Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

spi: Revert "spi: Insert the missing pci_dev_put()before return"

Commit 8a0ec8c2d736 ("spi: Insert the missing pci_dev_put()before
return") added two uses of pci_dev_put() with an uninitialized dma_dev,
resulting in the following compiler warnings (or errors with
CONFIG_WERROR) when building with clang:

drivers/spi/spi-pxa2xx-pci.c:150:15: error: variable 'dma_dev' is uninitialized when used here [-Werror,-Wuninitialized]
150 | pci_dev_put(dma_dev);
| ^~~~~~~
drivers/spi/spi-pxa2xx-pci.c:228:15: error: variable 'dma_dev' is uninitialized when used here [-Werror,-Wuninitialized]
228 | pci_dev_put(dma_dev);
| ^~~~~~~

Commit 609d7ffdc421 ("spi: pxa2xx-pci: Balance reference count for PCI
DMA device") added a call to pci_dev_put() via
devm_add_action_or_reset() in case of failures, so the recent change was
incorrect for multiple reasons. Revert it altogether.

Fixes: 8a0ec8c2d736 ("spi: Insert the missing pci_dev_put()before return")
Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Closes: https://lore.kernel.org/CAMuHMdWNjo69_W6f+R9QJJOf8uF0htg2XazeS-yjugJv3UM+kg@mail.gmail.com/
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Link: https://patch.msgid.link/20240902-spi-revert-8a0ec8c2d736-v1-1-928b829fed2b@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Nathan Chancellor and committed by
Mark Brown
bf62a8c7 f626a0cd

+2 -6
+2 -6
drivers/spi/spi-pxa2xx-pci.c
··· 145 145 c->num_chipselect = 1; 146 146 147 147 ret = pxa2xx_spi_pci_clk_register(dev, ssp, 50000000); 148 - if (ret) { 149 - pci_dev_put(dma_dev); 148 + if (ret) 150 149 return ret; 151 - } 152 150 153 151 dma_dev = pci_get_slot(dev->bus, PCI_DEVFN(PCI_SLOT(dev->devfn), 0)); 154 152 ret = devm_add_action_or_reset(&dev->dev, lpss_dma_put_device, dma_dev); ··· 221 223 } 222 224 223 225 ret = pxa2xx_spi_pci_clk_register(dev, ssp, 25000000); 224 - if (ret) { 225 - pci_dev_put(dma_dev); 226 + if (ret) 226 227 return ret; 227 - } 228 228 229 229 dma_dev = pci_get_slot(dev->bus, PCI_DEVFN(21, 0)); 230 230 ret = devm_add_action_or_reset(&dev->dev, lpss_dma_put_device, dma_dev);