]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
MIPS: Alchemy: Switch to use kmemdup_array()
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Thu, 6 Jun 2024 16:51:45 +0000 (19:51 +0300)
committerThomas Bogendoerfer <tsbogend@alpha.franken.de>
Tue, 11 Jun 2024 08:13:36 +0000 (10:13 +0200)
Let the kememdup_array() take care about multiplication and possible
overflows.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
arch/mips/alchemy/common/platform.c

index d4ab34b3b404efbda2083472210bc8e78efdd8e1..da74cae6b43a609cc9ed44d4f4af95afb2d6d869 100644 (file)
@@ -409,8 +409,8 @@ static void __init alchemy_setup_macs(int ctype)
        if (alchemy_get_macs(ctype) < 1)
                return;
 
-       macres = kmemdup(au1xxx_eth0_resources[ctype],
-                        sizeof(struct resource) * MAC_RES_COUNT, GFP_KERNEL);
+       macres = kmemdup_array(au1xxx_eth0_resources[ctype], MAC_RES_COUNT,
+                              sizeof(*macres), GFP_KERNEL);
        if (!macres) {
                printk(KERN_INFO "Alchemy: no memory for MAC0 resources\n");
                return;
@@ -430,8 +430,8 @@ static void __init alchemy_setup_macs(int ctype)
        if (alchemy_get_macs(ctype) < 2)
                return;
 
-       macres = kmemdup(au1xxx_eth1_resources[ctype],
-                        sizeof(struct resource) * MAC_RES_COUNT, GFP_KERNEL);
+       macres = kmemdup_array(au1xxx_eth1_resources[ctype], MAC_RES_COUNT,
+                              sizeof(*macres), GFP_KERNEL);
        if (!macres) {
                printk(KERN_INFO "Alchemy: no memory for MAC1 resources\n");
                return;