linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] spi: add missing pci_dev_put() before return
@ 2022-02-15  1:59 Qing Wang
  2022-02-23  7:44 ` Geert Uytterhoeven
  2022-02-23 19:09 ` Andy Shevchenko
  0 siblings, 2 replies; 6+ messages in thread
From: Qing Wang @ 2022-02-15  1:59 UTC (permalink / raw)
  To: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Mark Brown,
	linux-arm-kernel, linux-spi, linux-kernel
  Cc: Wang Qing

From: Wang Qing <wangqing@vivo.com>

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

Signed-off-by: Wang Qing <wangqing@vivo.com>
---
 drivers/spi/spi-pxa2xx-pci.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/spi/spi-pxa2xx-pci.c b/drivers/spi/spi-pxa2xx-pci.c
index 2e134eb..5fb2f44
--- a/drivers/spi/spi-pxa2xx-pci.c
+++ b/drivers/spi/spi-pxa2xx-pci.c
@@ -102,6 +102,8 @@ static int lpss_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c)
 	}
 
 	c->dma_filter = lpss_dma_filter;
+	pci_dev_put(dma_dev);
+
 	return 0;
 }
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] spi: add missing pci_dev_put() before return
  2022-02-15  1:59 [PATCH] spi: add missing pci_dev_put() before return Qing Wang
@ 2022-02-23  7:44 ` Geert Uytterhoeven
  2022-02-23 19:09 ` Andy Shevchenko
  1 sibling, 0 replies; 6+ messages in thread
From: Geert Uytterhoeven @ 2022-02-23  7:44 UTC (permalink / raw)
  To: Qing Wang
  Cc: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Mark Brown,
	Linux ARM, linux-spi, Linux Kernel Mailing List

Hi Qing,

On Tue, Feb 15, 2022 at 3:08 AM Qing Wang <wangqing@vivo.com> wrote:
> From: Wang Qing <wangqing@vivo.com>
>
> pci_get_slot() increases its reference count, the caller must
> decrement the reference count by calling pci_dev_put()
>
> Signed-off-by: Wang Qing <wangqing@vivo.com>

Thanks for your patch!

Please use "spi: spi-topcliff-pch:" instead of just "spi:" in the patch
summary, as this is specific to the spi-topcliff-pch driver, not to the SPI
core.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] spi: add missing pci_dev_put() before return
  2022-02-15  1:59 [PATCH] spi: add missing pci_dev_put() before return Qing Wang
  2022-02-23  7:44 ` Geert Uytterhoeven
@ 2022-02-23 19:09 ` Andy Shevchenko
  1 sibling, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2022-02-23 19:09 UTC (permalink / raw)
  To: Qing Wang
  Cc: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Mark Brown,
	linux-arm Mailing List, linux-spi, Linux Kernel Mailing List

On Tue, Feb 15, 2022 at 6:04 AM Qing Wang <wangqing@vivo.com> wrote:
>
> From: Wang Qing <wangqing@vivo.com>
>
> pci_get_slot() increases its reference count, the caller must
> decrement the reference count by calling pci_dev_put()

Thanks for the report!

This is not fully correct. I'll send a patch soon.

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] spi: add missing pci_dev_put() before return
  2022-02-23  4:08 ` Mark Brown
@ 2022-02-23 20:12   ` Christophe JAILLET
  0 siblings, 0 replies; 6+ messages in thread
From: Christophe JAILLET @ 2022-02-23 20:12 UTC (permalink / raw)
  To: Mark Brown, Qing Wang, linux-spi, linux-kernel

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 <wangqing-DGpbCiVdSXo@public.gmane.org>
>>
>> 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] spi: add missing pci_dev_put() before return
  2022-02-15  2:00 Qing Wang
@ 2022-02-23  4:08 ` Mark Brown
  2022-02-23 20:12   ` Christophe JAILLET
  0 siblings, 1 reply; 6+ messages in thread
From: Mark Brown @ 2022-02-23  4:08 UTC (permalink / raw)
  To: Qing Wang, linux-spi, linux-kernel

On Mon, 14 Feb 2022 18:00:07 -0800, Qing Wang wrote:
> From: Wang Qing <wangqing@vivo.com>
> 
> 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] spi: add missing pci_dev_put() before return
@ 2022-02-15  2:00 Qing Wang
  2022-02-23  4:08 ` Mark Brown
  0 siblings, 1 reply; 6+ messages in thread
From: Qing Wang @ 2022-02-15  2:00 UTC (permalink / raw)
  To: Mark Brown, linux-spi, linux-kernel; +Cc: Wang Qing

From: Wang Qing <wangqing@vivo.com>

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

Signed-off-by: Wang Qing <wangqing@vivo.com>
---
 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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-02-23 20:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-15  1:59 [PATCH] spi: add missing pci_dev_put() before return Qing Wang
2022-02-23  7:44 ` Geert Uytterhoeven
2022-02-23 19:09 ` Andy Shevchenko
2022-02-15  2:00 Qing Wang
2022-02-23  4:08 ` Mark Brown
2022-02-23 20:12   ` Christophe JAILLET

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).