Skip to contentSkip to conversation

isdn: hfcpci: check the return value of dma_set_mask() in setup_hw()

PATCH New Jia-Ju Bai 1 participant 1 message Mar 5, 2022

Subsystems (2)
lore
Share & tools
lore

Jia-Ju Bai

author
#0 lore raw

PATCH v2 1/1 isdn: hfcpci: check the return value of dma_set_mask() in setup_hw()

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

Fixes 1700fe1a10dc ("Add mISDN HFC PCI driver")

---
v2:
* Correct the fixes tag.
Thank Jakub for good advice.

---
 drivers/isdn/hardware/mISDN/hfcpci.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/isdn/hardware/mISDN/hfcpci.c +5 -1
index bd087cca1c1d..af17459c1a5c 100644
@@ -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 */
Signature · 1 line
2.17.1