MIPS: BCM47xx: Use kmemdup rather than duplicating its implementation
authorAndrzej Hajda <[email protected]>
Fri, 7 Aug 2015 07:59:10 +0000 (09:59 +0200)
committerRalf Baechle <[email protected]>
Thu, 3 Sep 2015 10:08:11 +0000 (12:08 +0200)
The patch was generated using fixed coccinelle semantic patch
scripts/coccinelle/api/memdup.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2014320

Signed-off-by: Andrzej Hajda <[email protected]>
Acked-by: Hauke Mehrtens <[email protected]>
Cc: Hauke Mehrtens <[email protected]>
Cc: Rafał Miłecki <[email protected]>
Cc: Andrzej Hajda <[email protected]>
Cc: Bartlomiej Zolnierkiewicz <[email protected]>
Cc: Marek Szyprowski <[email protected]>
Cc: [email protected]
Cc: [email protected]
Patchwork: https://patchwork.linux-mips.org/patch/10898/
Signed-off-by: Ralf Baechle <[email protected]>
arch/mips/bcm47xx/buttons.c

index 08a4abf09a33e9b069680a965a9dbe3b69a091d9..52caa75bfe4e5eb1ec43b0e4152fbb1230d0ae21 100644 (file)
@@ -396,10 +396,9 @@ static int __init bcm47xx_buttons_copy(const struct gpio_keys_button *buttons,
 {
        size_t size = nbuttons * sizeof(*buttons);
 
-       bcm47xx_button_pdata.buttons = kmalloc(size, GFP_KERNEL);
+       bcm47xx_button_pdata.buttons = kmemdup(buttons, size, GFP_KERNEL);
        if (!bcm47xx_button_pdata.buttons)
                return -ENOMEM;
-       memcpy(bcm47xx_button_pdata.buttons, buttons, size);
        bcm47xx_button_pdata.nbuttons = nbuttons;
 
        return 0;