linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] PCI: endpoint: functions/pci-epf-test: Avoid DMA release when DMA is unsupported
@ 2020-04-22  7:24 Kunihiko Hayashi
  2020-04-22  7:56 ` Kishon Vijay Abraham I
  2020-05-05 11:27 ` Lorenzo Pieralisi
  0 siblings, 2 replies; 3+ messages in thread
From: Kunihiko Hayashi @ 2020-04-22  7:24 UTC (permalink / raw)
  To: Kishon Vijay Abraham I, Lorenzo Pieralisi, Bjorn Helgaas
  Cc: linux-pci, linux-kernel, Kunihiko Hayashi

When unbinding pci_epf_test, pci_epf_test_clean_dma_chan() is called in
pci_epf_test_unbind() even though epf_test->dma_supported is false.
As a result, dma_release_channel() will occur null pointer access because
dma_chan isn't set.

This avoids calling dma_release_channel() if epf_test->dma_supported
is false.

Fixes: a1d105d4ab8e ("PCI: endpoint: functions/pci-epf-test: Add DMA support to transfer data")
Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
---
 drivers/pci/endpoint/functions/pci-epf-test.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c
index 60330f3e..c89a956 100644
--- a/drivers/pci/endpoint/functions/pci-epf-test.c
+++ b/drivers/pci/endpoint/functions/pci-epf-test.c
@@ -187,6 +187,9 @@ static int pci_epf_test_init_dma_chan(struct pci_epf_test *epf_test)
  */
 static void pci_epf_test_clean_dma_chan(struct pci_epf_test *epf_test)
 {
+	if (!epf_test->dma_supported)
+		return;
+
 	dma_release_channel(epf_test->dma_chan);
 	epf_test->dma_chan = NULL;
 }
-- 
2.7.4


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

* Re: [PATCH v2] PCI: endpoint: functions/pci-epf-test: Avoid DMA release when DMA is unsupported
  2020-04-22  7:24 [PATCH v2] PCI: endpoint: functions/pci-epf-test: Avoid DMA release when DMA is unsupported Kunihiko Hayashi
@ 2020-04-22  7:56 ` Kishon Vijay Abraham I
  2020-05-05 11:27 ` Lorenzo Pieralisi
  1 sibling, 0 replies; 3+ messages in thread
From: Kishon Vijay Abraham I @ 2020-04-22  7:56 UTC (permalink / raw)
  To: Kunihiko Hayashi, Lorenzo Pieralisi, Bjorn Helgaas
  Cc: linux-pci, linux-kernel

Hi Kunihiko,

On 4/22/2020 12:54 PM, Kunihiko Hayashi wrote:
> When unbinding pci_epf_test, pci_epf_test_clean_dma_chan() is called in
> pci_epf_test_unbind() even though epf_test->dma_supported is false.
> As a result, dma_release_channel() will occur null pointer access because
> dma_chan isn't set.
> 
> This avoids calling dma_release_channel() if epf_test->dma_supported
> is false.
> 
> Fixes: a1d105d4ab8e ("PCI: endpoint: functions/pci-epf-test: Add DMA support to transfer data")
> Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>

Thank you for fixing this.

Acked-by: Kishon Vijay Abraham I <kishon@ti.com>

Regards
Kishon

> ---
>  drivers/pci/endpoint/functions/pci-epf-test.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c
> index 60330f3e..c89a956 100644
> --- a/drivers/pci/endpoint/functions/pci-epf-test.c
> +++ b/drivers/pci/endpoint/functions/pci-epf-test.c
> @@ -187,6 +187,9 @@ static int pci_epf_test_init_dma_chan(struct pci_epf_test *epf_test)
>   */
>  static void pci_epf_test_clean_dma_chan(struct pci_epf_test *epf_test)
>  {
> +	if (!epf_test->dma_supported)
> +		return;
> +
>  	dma_release_channel(epf_test->dma_chan);
>  	epf_test->dma_chan = NULL;
>  }
> 

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

* Re: [PATCH v2] PCI: endpoint: functions/pci-epf-test: Avoid DMA release when DMA is unsupported
  2020-04-22  7:24 [PATCH v2] PCI: endpoint: functions/pci-epf-test: Avoid DMA release when DMA is unsupported Kunihiko Hayashi
  2020-04-22  7:56 ` Kishon Vijay Abraham I
@ 2020-05-05 11:27 ` Lorenzo Pieralisi
  1 sibling, 0 replies; 3+ messages in thread
From: Lorenzo Pieralisi @ 2020-05-05 11:27 UTC (permalink / raw)
  To: Kunihiko Hayashi
  Cc: Kishon Vijay Abraham I, Bjorn Helgaas, linux-pci, linux-kernel

On Wed, Apr 22, 2020 at 04:24:47PM +0900, Kunihiko Hayashi wrote:
> When unbinding pci_epf_test, pci_epf_test_clean_dma_chan() is called in
> pci_epf_test_unbind() even though epf_test->dma_supported is false.
> As a result, dma_release_channel() will occur null pointer access because
> dma_chan isn't set.
> 
> This avoids calling dma_release_channel() if epf_test->dma_supported
> is false.
> 
> Fixes: a1d105d4ab8e ("PCI: endpoint: functions/pci-epf-test: Add DMA support to transfer data")
> Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
> ---
>  drivers/pci/endpoint/functions/pci-epf-test.c | 3 +++
>  1 file changed, 3 insertions(+)

Applied (with the proper Fixes: SHA-1 ID) to pci/endpoint, thanks.

Lorenzo

> diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c
> index 60330f3e..c89a956 100644
> --- a/drivers/pci/endpoint/functions/pci-epf-test.c
> +++ b/drivers/pci/endpoint/functions/pci-epf-test.c
> @@ -187,6 +187,9 @@ static int pci_epf_test_init_dma_chan(struct pci_epf_test *epf_test)
>   */
>  static void pci_epf_test_clean_dma_chan(struct pci_epf_test *epf_test)
>  {
> +	if (!epf_test->dma_supported)
> +		return;
> +
>  	dma_release_channel(epf_test->dma_chan);
>  	epf_test->dma_chan = NULL;
>  }
> -- 
> 2.7.4
> 

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

end of thread, other threads:[~2020-05-05 11:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-22  7:24 [PATCH v2] PCI: endpoint: functions/pci-epf-test: Avoid DMA release when DMA is unsupported Kunihiko Hayashi
2020-04-22  7:56 ` Kishon Vijay Abraham I
2020-05-05 11:27 ` Lorenzo Pieralisi

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).