m68k/bootinfo: Use kmemdup rather than duplicating its implementation
authorAndrzej Hajda <a.hajda@samsung.com>
Fri, 7 Aug 2015 07:59:09 +0000 (09:59 +0200)
committerGeert Uytterhoeven <geert@linux-m68k.org>
Mon, 10 Aug 2015 08:26:33 +0000 (10:26 +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 <a.hajda@samsung.com>
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
arch/m68k/kernel/bootinfo_proc.c

index 7ee853e1432b077b92da90623f71d56b8e0d75a5..2a33a9645ad822a3482fc29b7dd28baed5450fb7 100644 (file)
@@ -62,12 +62,10 @@ static int __init init_bootinfo_procfs(void)
        if (!bootinfo_size)
                return -EINVAL;
 
-       bootinfo_copy = kmalloc(bootinfo_size, GFP_KERNEL);
+       bootinfo_copy = kmemdup(bootinfo_tmp, bootinfo_size, GFP_KERNEL);
        if (!bootinfo_copy)
                return -ENOMEM;
 
-       memcpy(bootinfo_copy, bootinfo_tmp, bootinfo_size);
-
        pde = proc_create_data("bootinfo", 0400, NULL, &bootinfo_fops, NULL);
        if (!pde) {
                kfree(bootinfo_copy);