Skip to contentSkip to conversation

spi: add missing pci_dev_put() before return

PATCH In review Qing Wang 3 participants 3 messages Feb 15, 2022 – Feb 23, 2022 SPI

lore
Share & tools
lore

Qing Wang

author
#0 lore raw

PATCH 1/1 spi: add missing pci_dev_put() before return

From: Wang Qing <[email protected]>

pci_get_slot() increases its reference count, the caller must decrement the reference count by calling pci_dev_put()

---
 drivers/spi/spi-topcliff-pch.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/spi/spi-topcliff-pch.c +5 -2
index 8c4615b..8e1cc34
@@ -877,7 +877,7 @@ static void pch_spi_request_dma(struct pch_spi_data *data, int bpw)
 		dev_err(&data->master->dev,
 			"ERROR: dma_request_channel FAILS(Tx)\n");
 		data->use_dma = 0;
-		return;
+		goto out;
 	}
 	dma->chan_tx = chan;
 
@@ -894,9 +894,12 @@ static void pch_spi_request_dma(struct pch_spi_data *data, int bpw)
 		dma_release_channel(dma->chan_tx);
 		dma->chan_tx = NULL;
 		data->use_dma = 0;
-		return;
+		goto out;
 	}
 	dma->chan_rx = chan;
+
+out:
+	pci_dev_put(dma_dev);
 }
 
 static void pch_spi_release_dma(struct pch_spi_data *data)
Signature · 1 line
2.7.4
maintainer
#1 lore raw
Quoted 6 lines · Qing Wang

From: Wang Qing <[email protected]>

pci_get_slot() increases its reference count, the caller must decrement the reference count by calling pci_dev_put()

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[1/1] spi: add missing pci_dev_put() before return

      commit: 4d986ffa036a773456476f70bd0fde2fb1330b7d

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

#2 lore raw

Le 23/02/2022 à 05:08, Mark Brown a écrit :

Quoted 8 lines · Qing Wang
Quoted 6 lines

From: Wang Qing <[email protected]>

pci_get_slot() increases its reference count, the caller must decrement the reference count by calling pci_dev_put()

Quoted 9 lines

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[1/1] spi: add missing pci_dev_put() before return

       commit: 4d986ffa036a773456476f70bd0fde2fb1330b7d

Hi, not sure that the patch is correct.

Shouldn't the reference be released in the error handling path and in pch_spi_release_dma() ?

Instead of *unconditionally* at the end of pch_spi_request_dma()?

CJ