ARM: omap2: Switch to use kmemdup_array()
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Thu, 6 Jun 2024 16:51:04 +0000 (19:51 +0300)
committerKevin Hilman <khilman@baylibre.com>
Tue, 30 Jul 2024 22:19:44 +0000 (15:19 -0700)
Let the kmemdup_array() take care about multiplication and possible
overflows.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Link: https://lore.kernel.org/r/20240606165104.3031737-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Kevin Hilman <khilman@baylibre.com>
arch/arm/mach-omap2/omap_device.c

index fca7869c8075a3c841a56ad745d9dab7877f1866..800980057373b1845e28b8bb73d80b0e91da7c0e 100644 (file)
@@ -315,7 +315,7 @@ static struct omap_device *omap_device_alloc(struct platform_device *pdev,
 
        od->hwmods_cnt = oh_cnt;
 
-       hwmods = kmemdup(ohs, sizeof(struct omap_hwmod *) * oh_cnt, GFP_KERNEL);
+       hwmods = kmemdup_array(ohs, oh_cnt, sizeof(*hwmods), GFP_KERNEL);
        if (!hwmods)
                goto oda_exit2;