powerpc/pseries: use kmemdup rather than duplicating its implementation
authorAndrzej Hajda <a.hajda@samsung.com>
Fri, 7 Aug 2015 07:59:12 +0000 (09:59 +0200)
committerMichael Ellerman <mpe@ellerman.id.au>
Tue, 18 Aug 2015 09:34:42 +0000 (19:34 +1000)
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>
Reviewed-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/platforms/pseries/hotplug-memory.c

index 0ced387e14638f2a711fbca784ab621ac9121b1d..e9ff44cd5d86e3491eaa7c5a7a93c48156b480f1 100644 (file)
@@ -92,13 +92,12 @@ static struct property *dlpar_clone_drconf_property(struct device_node *dn)
                return NULL;
 
        new_prop->name = kstrdup(prop->name, GFP_KERNEL);
-       new_prop->value = kmalloc(prop->length, GFP_KERNEL);
+       new_prop->value = kmemdup(prop->value, prop->length, GFP_KERNEL);
        if (!new_prop->name || !new_prop->value) {
                dlpar_free_drconf_property(new_prop);
                return NULL;
        }
 
-       memcpy(new_prop->value, prop->value, prop->length);
        new_prop->length = prop->length;
 
        /* Convert the property to cpu endian-ness */