[PATCHv2 3/9] dmaengine: mv_xor: bound maximum channels for Armada 37xx

From: Rosen Penev

Date: Thu Jun 11 2026 - 17:08:02 EST


For XOR_ARMADA_37XX the driver set max_channels = num_present_cpus()
without bounding it by MV_XOR_MAX_CHANNELS (2). On a system with
more than 2 CPUs this lets the probe loop write past the end of the
xordev->channels[] array when the DT describes enough child nodes.
Add the missing min_t() guard.

Assisted-by: opencode:big-pickle
Fixes: ac5f0f3f863e ("dmaengine: mv_xor: add support for Armada 3700 SoC")
Signed-off-by: Rosen Penev <rosenp@xxxxxxxxx>
---
drivers/dma/mv_xor.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/mv_xor.c b/drivers/dma/mv_xor.c
index ef29e8be1db6..588af337afe3 100644
--- a/drivers/dma/mv_xor.c
+++ b/drivers/dma/mv_xor.c
@@ -1387,7 +1387,8 @@ static int mv_xor_probe(struct platform_device *pdev)
*/
max_engines = num_present_cpus();
if (xordev->xor_type == XOR_ARMADA_37XX)
- max_channels = num_present_cpus();
+ max_channels = min_t(unsigned int, MV_XOR_MAX_CHANNELS,
+ num_present_cpus());
else
max_channels = min_t(unsigned int,
MV_XOR_MAX_CHANNELS,
--
2.54.0