Skip to contentSkip to conversation

dmaengine: mxs-dma: Add check for dma_set_max_seg_size in mxs_dma_probe()

PATCH In review Ma Ke 4 participants 4 messages Jun 26, 2024

Subsystems (2)
lore
Share & tools
lore

Ma Ke

author
#0 lore raw

PATCH 1/1 dmaengine: mxs-dma: Add check for dma_set_max_seg_size in mxs_dma_probe()

As the possible failure of the dma_set_max_seg_size(), we should better check the return value of the dma_set_max_seg_size().

Fixes a580b8c5429a ("dmaengine: mxs-dma: add dma support for i.MX23/28")
---
 drivers/dma/mxs-dma.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/dma/mxs-dma.c +3 -1
index cfb9962417ef..90cbb9b04b02 100644
@@ -798,7 +798,9 @@ static int mxs_dma_probe(struct platform_device *pdev)
 	mxs_dma->dma_device.dev = &pdev->dev;
 
 	/* mxs_dma gets 65535 bytes maximum sg size */
-	dma_set_max_seg_size(mxs_dma->dma_device.dev, MAX_XFER_BYTES);
+	ret = dma_set_max_seg_size(mxs_dma->dma_device.dev, MAX_XFER_BYTES);
+	if (ret)
+		return ret;
 
 	mxs_dma->dma_device.device_alloc_chan_resources = mxs_dma_alloc_chan_resources;
 	mxs_dma->dma_device.device_free_chan_resources = mxs_dma_free_chan_resources;
Signature · 1 line
2.25.1
#1 lore raw
Quoted 2 lines

Subject: [PATCH] dmaengine: mxs-dma: Add check for dma_set_max_seg_size in mxs_dma_probe()

Please read
https://lore.kernel.org/all/ZiocjS6tbeTt2mPD@matsya/

Regards,
Peng.

Quoted 34 lines

As the possible failure of the dma_set_max_seg_size(), we should better check the return value of the dma_set_max_seg_size().

Fixes a580b8c5429a ("dmaengine: mxs-dma: add dma support for

i.MX23/28")

---
 drivers/dma/mxs-dma.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/dma/mxs-dma.c index renamed from drivers/dma/mxs-dma.c +0 -0

cfb9962417ef..90cbb9b04b02 100644

drivers/dma/mxs-dma.c +3 -1
@@ -798,7 +798,9 @@ static int mxs_dma_probe(struct
 platform_device *pdev)
 	mxs_dma->dma_device.dev = &pdev->dev;
 
 	/* mxs_dma gets 65535 bytes maximum sg size */
-	dma_set_max_seg_size(mxs_dma->dma_device.dev,
 MAX_XFER_BYTES);
+	ret = dma_set_max_seg_size(mxs_dma->dma_device.dev,
 MAX_XFER_BYTES);
+	if (ret)
+		return ret;

mxs_dma->dma_device.device_alloc_chan_resources =
mxs_dma_alloc_chan_resources;
mxs_dma->dma_device.device_free_chan_resources =
mxs_dma_free_chan_resources;
--
2.25.1

#2 lore raw

Hi

Quoted 29 lines · Peng Fan
Quoted 3 lines

Subject: [PATCH] dmaengine: mxs-dma: Add check for dma_set_max_seg_size in mxs_dma_probe()

Please read
https://lore.kernel.org/all/ZiocjS6tbeTt2mPD@matsya/

Regards,
Peng.

Quoted 19 lines

As the possible failure of the dma_set_max_seg_size(), we should better check the return value of the dma_set_max_seg_size().

Fixes a580b8c5429a ("dmaengine: mxs-dma: add dma support for

i.MX23/28")

---
 drivers/dma/mxs-dma.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/dma/mxs-dma.c index renamed from drivers/dma/mxs-dma.c +0 -0

cfb9962417ef..90cbb9b04b02 100644

drivers/dma/mxs-dma.c +0 -0
@@ -798,7 +798,9 @@ static int mxs_dma_probe(struct
 platform_device *pdev)
      mxs_dma->dma_device.dev = &pdev->dev;
 
Quoted 8 lines

drivers/dma/mxs-dma.c static int mxs_dma_probe(struct · line 806

Quoted 8 lines
drivers/dma/mxs-dma.c +3 -1
      /* mxs_dma gets 65535 bytes maximum sg size */
-     dma_set_max_seg_size(mxs_dma->dma_device.dev,
 MAX_XFER_BYTES);
+     ret = dma_set_max_seg_size(mxs_dma->dma_device.dev,
 MAX_XFER_BYTES);
+     if (ret)
+             return ret;

If the function returns an error then you should check for it. If it's not logical to have it, then you could
make void the function that is called and WARN_ON on an illogical situation

Michael

Quoted 9 lines
Quoted 7 lines
      mxs_dma->dma_device.device_alloc_chan_resources =
mxs_dma_alloc_chan_resources;
      mxs_dma->dma_device.device_free_chan_resources =

mxs_dma_free_chan_resources;
--
2.25.1