* [PATCH] dmaengine: stm32-mdma: Add missing check for device_property_read_u32_array
@ 2026-01-28 4:23 Chen Ni
2026-01-28 10:02 ` Markus Elfring
2026-01-28 10:23 ` Amelie Delaunay
0 siblings, 2 replies; 3+ messages in thread
From: Chen Ni @ 2026-01-28 4:23 UTC (permalink / raw)
To: amelie.delaunay, vkoul, mcoquelin.stm32, alexandre.torgue
Cc: dmaengine, linux-stm32, linux-arm-kernel, linux-kernel, Chen Ni
Add check for the return value of device_property_read_u32_array() and
return the error if it fails in order to catch the error.
Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
---
drivers/dma/stm32/stm32-mdma.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/dma/stm32/stm32-mdma.c b/drivers/dma/stm32/stm32-mdma.c
index b87d41b234df..f833724cf42c 100644
--- a/drivers/dma/stm32/stm32-mdma.c
+++ b/drivers/dma/stm32/stm32-mdma.c
@@ -1630,9 +1630,11 @@ static int stm32_mdma_probe(struct platform_device *pdev)
dmadev->nr_channels = nr_channels;
dmadev->nr_requests = nr_requests;
- device_property_read_u32_array(&pdev->dev, "st,ahb-addr-masks",
- dmadev->ahb_addr_masks,
- count);
+ ret = device_property_read_u32_array(&pdev->dev, "st,ahb-addr-masks",
+ dmadev->ahb_addr_masks,
+ count);
+ if (ret)
+ return ret;
dmadev->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(dmadev->base))
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] dmaengine: stm32-mdma: Add missing check for device_property_read_u32_array
2026-01-28 4:23 [PATCH] dmaengine: stm32-mdma: Add missing check for device_property_read_u32_array Chen Ni
@ 2026-01-28 10:02 ` Markus Elfring
2026-01-28 10:23 ` Amelie Delaunay
1 sibling, 0 replies; 3+ messages in thread
From: Markus Elfring @ 2026-01-28 10:02 UTC (permalink / raw)
To: Chen Ni, dmaengine, linux-arm-kernel, linux-stm32
Cc: LKML, Alexandre Torgue, Amelie Delaunay, Maxime Coquelin,
Vinod Koul
> Add check for the return value of device_property_read_u32_array() and
> return the error if it fails in order to catch the error.
* Were any source code analysis tools involved here?
* Did anything hinder to add any tags (like “Fixes” and “Cc”) accordingly?
Regards,
Markus
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] dmaengine: stm32-mdma: Add missing check for device_property_read_u32_array
2026-01-28 4:23 [PATCH] dmaengine: stm32-mdma: Add missing check for device_property_read_u32_array Chen Ni
2026-01-28 10:02 ` Markus Elfring
@ 2026-01-28 10:23 ` Amelie Delaunay
1 sibling, 0 replies; 3+ messages in thread
From: Amelie Delaunay @ 2026-01-28 10:23 UTC (permalink / raw)
To: Chen Ni, vkoul, mcoquelin.stm32, alexandre.torgue
Cc: dmaengine, linux-stm32, linux-arm-kernel, linux-kernel
On 1/28/26 05:23, Chen Ni wrote:
> Add check for the return value of device_property_read_u32_array() and
> return the error if it fails in order to catch the error.
>
> Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
> ---
> drivers/dma/stm32/stm32-mdma.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/dma/stm32/stm32-mdma.c b/drivers/dma/stm32/stm32-mdma.c
> index b87d41b234df..f833724cf42c 100644
> --- a/drivers/dma/stm32/stm32-mdma.c
> +++ b/drivers/dma/stm32/stm32-mdma.c
> @@ -1630,9 +1630,11 @@ static int stm32_mdma_probe(struct platform_device *pdev)
>
> dmadev->nr_channels = nr_channels;
> dmadev->nr_requests = nr_requests;
> - device_property_read_u32_array(&pdev->dev, "st,ahb-addr-masks",
> - dmadev->ahb_addr_masks,
> - count);
> + ret = device_property_read_u32_array(&pdev->dev, "st,ahb-addr-masks",
> + dmadev->ahb_addr_masks,
> + count);
> + if (ret)
> + return ret;
Your patch breaks MDMA on STM32MP1x platforms because
"st,ahb-addr-masks" is an optional property. That is why the return
value of device_property_read_u32_array() is intentionally ignored.
Count is used to check the presence of the property and to allocate
dmadev->ahb_addr_masks accordingly:
count = device_property_count_u32(&pdev->dev, "st,ahb-addr-masks");
if (count < 0)
count = 0;
[...]
dmadev->nr_ahb_addr_masks = count;
If the property is not present, dmadev->nr_ahb_addr_masks is set to 0,
and MDMA behaves correctly.
With your patch, when the property is missing, the MDMA probe fails
because device_property_read_u32_array() returns -EINVAL. This is
incorrect since "st,ahb-addr-masks" is an optional property, not a
required one.
Regards,
Amelie
>
> dmadev->base = devm_platform_ioremap_resource(pdev, 0);
> if (IS_ERR(dmadev->base))
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-01-28 10:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-28 4:23 [PATCH] dmaengine: stm32-mdma: Add missing check for device_property_read_u32_array Chen Ni
2026-01-28 10:02 ` Markus Elfring
2026-01-28 10:23 ` Amelie Delaunay
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox