PCI: pnv_php: Use kmemdup()
authorYueHaibing <yuehaibing@huawei.com>
Thu, 27 Sep 2018 06:52:21 +0000 (06:52 +0000)
committerBjorn Helgaas <bhelgaas@google.com>
Tue, 2 Oct 2018 21:04:40 +0000 (16:04 -0500)
Use kmemdup() rather than duplicating its implementation.

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Michael Ellerman <mpe@ellerman.id.au>
drivers/pci/hotplug/pnv_php.c

index 5070620..ee54f5b 100644 (file)
@@ -275,14 +275,13 @@ static int pnv_php_add_devtree(struct pnv_php_slot *php_slot)
                goto free_fdt1;
        }
 
-       fdt = kzalloc(fdt_totalsize(fdt1), GFP_KERNEL);
+       fdt = kmemdup(fdt1, fdt_totalsize(fdt1), GFP_KERNEL);
        if (!fdt) {
                ret = -ENOMEM;
                goto free_fdt1;
        }
 
        /* Unflatten device tree blob */
-       memcpy(fdt, fdt1, fdt_totalsize(fdt1));
        dt = of_fdt_unflatten_tree(fdt, php_slot->dn, NULL);
        if (!dt) {
                ret = -EINVAL;