[PATCH 2/3] remoteproc: virtio: replace kmemdup with kmemdup_array

From: Francesco Valla

Date: Sat Oct 10 2026 - 11:21:33 EST


Let kmemdup_array take care of multiplication and overflows.

While at it, add blank lines in the same function for readability.

Signed-off-by: Francesco Valla <francesco@xxxxxxxx>
---
drivers/remoteproc/remoteproc_virtio.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c
index dcafdfa7eab6..6db228a9f87a 100644
--- a/drivers/remoteproc/remoteproc_virtio.c
+++ b/drivers/remoteproc/remoteproc_virtio.c
@@ -37,11 +37,12 @@ static int copy_dma_range_map(struct device *to, struct device *from)
for (r = map; r->size; r++)
num_ranges++;

- new_map = kmemdup(map, array_size(num_ranges + 1, sizeof(*map)),
- GFP_KERNEL);
+ new_map = kmemdup_array(map, num_ranges + 1, sizeof(*map), GFP_KERNEL);
if (!new_map)
return -ENOMEM;
+
to->dma_range_map = new_map;
+
return 0;
}


--
2.56.0