linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PCI: endpoint: functions/pci-epf-test: Avoid DMA release when DMA is unsupported
@ 2020-03-23  9:45 Kunihiko Hayashi
  2020-04-22  5:12 ` Kunihiko Hayashi
  2020-04-22  5:45 ` Kishon Vijay Abraham I
  0 siblings, 2 replies; 4+ messages in thread
From: Kunihiko Hayashi @ 2020-03-23  9:45 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, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c
index 3b4cf7e..8b4f136 100644
--- a/drivers/pci/endpoint/functions/pci-epf-test.c
+++ b/drivers/pci/endpoint/functions/pci-epf-test.c
@@ -609,7 +609,8 @@ static void pci_epf_test_unbind(struct pci_epf *epf)
 	int bar;
 
 	cancel_delayed_work(&epf_test->cmd_handler);
-	pci_epf_test_clean_dma_chan(epf_test);
+	if (epf_test->dma_supported)
+		pci_epf_test_clean_dma_chan(epf_test);
 	pci_epc_stop(epc);
 	for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) {
 		epf_bar = &epf->bar[bar];
-- 
2.7.4


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

* Re: [PATCH] PCI: endpoint: functions/pci-epf-test: Avoid DMA release when DMA is unsupported
  2020-03-23  9:45 [PATCH] PCI: endpoint: functions/pci-epf-test: Avoid DMA release when DMA is unsupported Kunihiko Hayashi
@ 2020-04-22  5:12 ` Kunihiko Hayashi
  2020-04-22  5:45 ` Kishon Vijay Abraham I
  1 sibling, 0 replies; 4+ messages in thread
From: Kunihiko Hayashi @ 2020-04-22  5:12 UTC (permalink / raw)
  To: Kishon Vijay Abraham I, Lorenzo Pieralisi, Bjorn Helgaas
  Cc: linux-pci, linux-kernel

On 2020/03/23 18:45, 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, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c
> index 3b4cf7e..8b4f136 100644
> --- a/drivers/pci/endpoint/functions/pci-epf-test.c
> +++ b/drivers/pci/endpoint/functions/pci-epf-test.c
> @@ -609,7 +609,8 @@ static void pci_epf_test_unbind(struct pci_epf *epf)
>   	int bar;
>   
>   	cancel_delayed_work(&epf_test->cmd_handler);
> -	pci_epf_test_clean_dma_chan(epf_test);
> +	if (epf_test->dma_supported)
> +		pci_epf_test_clean_dma_chan(epf_test);
>   	pci_epc_stop(epc);
>   	for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) {
>   		epf_bar = &epf->bar[bar];
> 

Gentle ping.
Are there any comments about that?

Thank you,

---
Best Regards
Kunihiko Hayashi

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

* Re: [PATCH] PCI: endpoint: functions/pci-epf-test: Avoid DMA release when DMA is unsupported
  2020-03-23  9:45 [PATCH] PCI: endpoint: functions/pci-epf-test: Avoid DMA release when DMA is unsupported Kunihiko Hayashi
  2020-04-22  5:12 ` Kunihiko Hayashi
@ 2020-04-22  5:45 ` Kishon Vijay Abraham I
  2020-04-22  5:59   ` Kunihiko Hayashi
  1 sibling, 1 reply; 4+ messages in thread
From: Kishon Vijay Abraham I @ 2020-04-22  5:45 UTC (permalink / raw)
  To: Kunihiko Hayashi, Lorenzo Pieralisi, Bjorn Helgaas
  Cc: linux-pci, linux-kernel

Hi Kunihiko,

On 3/23/2020 3:15 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>
> ---
>  drivers/pci/endpoint/functions/pci-epf-test.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c
> index 3b4cf7e..8b4f136 100644
> --- a/drivers/pci/endpoint/functions/pci-epf-test.c
> +++ b/drivers/pci/endpoint/functions/pci-epf-test.c
> @@ -609,7 +609,8 @@ static void pci_epf_test_unbind(struct pci_epf *epf)
>  	int bar;
>  
>  	cancel_delayed_work(&epf_test->cmd_handler);
> -	pci_epf_test_clean_dma_chan(epf_test);
> +	if (epf_test->dma_supported)
> +		pci_epf_test_clean_dma_chan(epf_test);

Can you add this check inside the pci_epf_test_clean_dma_chan()?

Thanks
Kishon

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

* Re: [PATCH] PCI: endpoint: functions/pci-epf-test: Avoid DMA release when DMA is unsupported
  2020-04-22  5:45 ` Kishon Vijay Abraham I
@ 2020-04-22  5:59   ` Kunihiko Hayashi
  0 siblings, 0 replies; 4+ messages in thread
From: Kunihiko Hayashi @ 2020-04-22  5:59 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: Lorenzo Pieralisi, Bjorn Helgaas, linux-pci, linux-kernel

Hi Kishon,

On 2020/04/22 14:45, Kishon Vijay Abraham I wrote:
> Hi Kunihiko,
> 
> On 3/23/2020 3:15 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>
>> ---
>>   drivers/pci/endpoint/functions/pci-epf-test.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c
>> index 3b4cf7e..8b4f136 100644
>> --- a/drivers/pci/endpoint/functions/pci-epf-test.c
>> +++ b/drivers/pci/endpoint/functions/pci-epf-test.c
>> @@ -609,7 +609,8 @@ static void pci_epf_test_unbind(struct pci_epf *epf)
>>   	int bar;
>>   
>>   	cancel_delayed_work(&epf_test->cmd_handler);
>> -	pci_epf_test_clean_dma_chan(epf_test);
>> +	if (epf_test->dma_supported)
>> +		pci_epf_test_clean_dma_chan(epf_test);
> 
> Can you add this check inside the pci_epf_test_clean_dma_chan()?
Okay, I'll move this check to the pci_epf_test_clean_dma_chan().

Thank you,

---
Best Regards
Kunihiko Hayashi

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

end of thread, other threads:[~2020-04-22  5:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-23  9:45 [PATCH] PCI: endpoint: functions/pci-epf-test: Avoid DMA release when DMA is unsupported Kunihiko Hayashi
2020-04-22  5:12 ` Kunihiko Hayashi
2020-04-22  5:45 ` Kishon Vijay Abraham I
2020-04-22  5:59   ` Kunihiko Hayashi

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