netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] isdn: hfcpci: check the return value of dma_set_mask() in setup_hw()
@ 2022-03-03  2:57 Jia-Ju Bai
  2022-03-04  5:15 ` Jakub Kicinski
  0 siblings, 1 reply; 3+ messages in thread
From: Jia-Ju Bai @ 2022-03-03  2:57 UTC (permalink / raw)
  To: isdn, davem, zou_wei, zheyuma97; +Cc: netdev, linux-kernel, Jia-Ju Bai

The function dma_set_mask() in setup_hw() can fail, so its return value
should be checked.

Fixes: e85da794f658 ("mISDN: switch from 'pci_' to 'dma_' API")
Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
---
 drivers/isdn/hardware/mISDN/hfcpci.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/isdn/hardware/mISDN/hfcpci.c b/drivers/isdn/hardware/mISDN/hfcpci.c
index bd087cca1c1d..af17459c1a5c 100644
--- a/drivers/isdn/hardware/mISDN/hfcpci.c
+++ b/drivers/isdn/hardware/mISDN/hfcpci.c
@@ -2005,7 +2005,11 @@ setup_hw(struct hfc_pci *hc)
 	}
 	/* Allocate memory for FIFOS */
 	/* the memory needs to be on a 32k boundary within the first 4G */
-	dma_set_mask(&hc->pdev->dev, 0xFFFF8000);
+	if (dma_set_mask(&hc->pdev->dev, 0xFFFF8000)) {
+		printk(KERN_WARNING
+		       "HFC-PCI: No usable DMA configuration!\n");
+		return -EIO;
+	}
 	buffer = dma_alloc_coherent(&hc->pdev->dev, 0x8000, &hc->hw.dmahandle,
 				    GFP_KERNEL);
 	/* We silently assume the address is okay if nonzero */
-- 
2.17.1


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

* Re: [PATCH] isdn: hfcpci: check the return value of dma_set_mask() in setup_hw()
  2022-03-03  2:57 [PATCH] isdn: hfcpci: check the return value of dma_set_mask() in setup_hw() Jia-Ju Bai
@ 2022-03-04  5:15 ` Jakub Kicinski
  2022-03-05  8:34   ` Jia-Ju Bai
  0 siblings, 1 reply; 3+ messages in thread
From: Jakub Kicinski @ 2022-03-04  5:15 UTC (permalink / raw)
  To: Jia-Ju Bai; +Cc: isdn, davem, zou_wei, zheyuma97, netdev, linux-kernel

On Wed,  2 Mar 2022 18:57:10 -0800 Jia-Ju Bai wrote:
> The function dma_set_mask() in setup_hw() can fail, so its return value
> should be checked.
> 
> Fixes: e85da794f658 ("mISDN: switch from 'pci_' to 'dma_' API")

The change under Fixes only switched the helper the driver uses,
it did not introduce the problem. The Fixes tag should point to 
the earliest commit where the problem is present.

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

* Re: [PATCH] isdn: hfcpci: check the return value of dma_set_mask() in setup_hw()
  2022-03-04  5:15 ` Jakub Kicinski
@ 2022-03-05  8:34   ` Jia-Ju Bai
  0 siblings, 0 replies; 3+ messages in thread
From: Jia-Ju Bai @ 2022-03-05  8:34 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: isdn, davem, zou_wei, zheyuma97, netdev, linux-kernel



On 2022/3/4 13:15, Jakub Kicinski wrote:
> On Wed,  2 Mar 2022 18:57:10 -0800 Jia-Ju Bai wrote:
>> The function dma_set_mask() in setup_hw() can fail, so its return value
>> should be checked.
>>
>> Fixes: e85da794f658 ("mISDN: switch from 'pci_' to 'dma_' API")
> The change under Fixes only switched the helper the driver uses,
> it did not introduce the problem. The Fixes tag should point to
> the earliest commit where the problem is present.

Hi Jakub,

Thanks for the advice.
I will send a V2 patch.


Best wishes,
Jia-Ju Bai

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

end of thread, other threads:[~2022-03-05  8:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-03  2:57 [PATCH] isdn: hfcpci: check the return value of dma_set_mask() in setup_hw() Jia-Ju Bai
2022-03-04  5:15 ` Jakub Kicinski
2022-03-05  8:34   ` Jia-Ju Bai

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