Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: Alchemy: Switch to use kmemdup_array()

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>

authored by

Andy Shevchenko and committed by
Thomas Bogendoerfer
bc2e65bf 83a7eefe

+4 -4
+4 -4
arch/mips/alchemy/common/platform.c
··· 409 409 if (alchemy_get_macs(ctype) < 1) 410 410 return; 411 411 412 - macres = kmemdup(au1xxx_eth0_resources[ctype], 413 - sizeof(struct resource) * MAC_RES_COUNT, GFP_KERNEL); 412 + macres = kmemdup_array(au1xxx_eth0_resources[ctype], MAC_RES_COUNT, 413 + sizeof(*macres), GFP_KERNEL); 414 414 if (!macres) { 415 415 printk(KERN_INFO "Alchemy: no memory for MAC0 resources\n"); 416 416 return; ··· 430 430 if (alchemy_get_macs(ctype) < 2) 431 431 return; 432 432 433 - macres = kmemdup(au1xxx_eth1_resources[ctype], 434 - sizeof(struct resource) * MAC_RES_COUNT, GFP_KERNEL); 433 + macres = kmemdup_array(au1xxx_eth1_resources[ctype], MAC_RES_COUNT, 434 + sizeof(*macres), GFP_KERNEL); 435 435 if (!macres) { 436 436 printk(KERN_INFO "Alchemy: no memory for MAC1 resources\n"); 437 437 return;