Skip to contentSkip to conversation

dma: xilinx: check the return value of dma_set_mask() in zynqmp_dma_probe()

PATCH In review Jia-Ju Bai 2 participants 2 messages Mar 5, 2022 – Mar 8, 2022

Subsystems (2)
lore
Share & tools
lore

Jia-Ju Bai

author
#0 lore raw

PATCH v2 1/1 dma: xilinx: check the return value of dma_set_mask() in zynqmp_dma_probe()

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

Fixes b0cc417c1637 ("dmaengine: Add Xilinx zynqmp dma engine driver support")

---
v2:
* Print an error message and forward the return value of dma_set_mask(). Thank Michael for good advice.

---
 drivers/dma/xilinx/zynqmp_dma.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/dma/xilinx/zynqmp_dma.c +4 -1
index 7aa63b652027..2791e9c6a4ea 100644
@@ -1050,7 +1050,10 @@ static int zynqmp_dma_probe(struct platform_device *pdev)
 	zdev->dev = &pdev->dev;
 	INIT_LIST_HEAD(&zdev->common.channels);
 
-	dma_set_mask(&pdev->dev, DMA_BIT_MASK(44));
+	ret = dma_set_mask(&pdev->dev, DMA_BIT_MASK(44));
+	if (ret)
+		return dev_err_probe(&pdev->dev, ret, "No usable DMA available\n");
+
 	dma_cap_set(DMA_MEMCPY, zdev->common.cap_mask);
 
 	p = &zdev->common;
Signature · 1 line
2.17.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 6 lines · Jia-Ju Bai

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

Fixes b0cc417c1637 ("dmaengine: Add Xilinx zynqmp dma engine driver support")
Quoted 29 lines

---
v2:
* Print an error message and forward the return value of dma_set_mask(). Thank Michael for good advice.

---
 drivers/dma/xilinx/zynqmp_dma.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/dma/xilinx/zynqmp_dma.c +4 -1
index 7aa63b652027..2791e9c6a4ea 100644
@@ -1050,7 +1050,10 @@ static int zynqmp_dma_probe(struct platform_device *pdev)
 	zdev->dev = &pdev->dev;
 	INIT_LIST_HEAD(&zdev->common.channels);
 
-	dma_set_mask(&pdev->dev, DMA_BIT_MASK(44));
+	ret = dma_set_mask(&pdev->dev, DMA_BIT_MASK(44));
+	if (ret)
+		return dev_err_probe(&pdev->dev, ret, "No usable DMA available\n");
+
 	dma_cap_set(DMA_MEMCPY, zdev->common.cap_mask);
 
 	p = &zdev->common;
Signature · 1 line
2.17.1