2022-02-15 02:47:38

by 王擎

[permalink] [raw]
Subject: [PATCH] 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()

Signed-off-by: Wang Qing <[email protected]>
---
drivers/spi/spi-topcliff-pch.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-topcliff-pch.c b/drivers/spi/spi-topcliff-pch.c
index 8c4615b..8e1cc34
--- a/drivers/spi/spi-topcliff-pch.c
+++ b/drivers/spi/spi-topcliff-pch.c
@@ -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)
--
2.7.4


2022-02-23 11:19:15

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH] spi: add missing pci_dev_put() before return

On Mon, 14 Feb 2022 18:00:07 -0800, Qing Wang wrote:
> 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

2022-02-23 20:36:45

by Christophe JAILLET

[permalink] [raw]
Subject: Re: [PATCH] spi: add missing pci_dev_put() before return

Le 23/02/2022 à 05:08, Mark Brown a écrit :
> On Mon, 14 Feb 2022 18:00:07 -0800, Qing Wang wrote:
>> 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
>

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