ACPI: use kstrdup()
authorThomas Meyer <thomas@m3y3r.de>
Sat, 6 Aug 2011 09:32:56 +0000 (11:32 +0200)
committerLen Brown <len.brown@intel.com>
Mon, 7 Nov 2011 00:13:44 +0000 (19:13 -0500)
 Use kstrdup rather than duplicating its implementation

 The semantic patch that makes this output is available
 in scripts/coccinelle/api/kstrdup.cocci.

 More information about semantic patching is available at
 http://coccinelle.lip6.fr/

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
Signed-off-by: Len Brown <len.brown@intel.com>
drivers/acpi/scan.c

index 449c556274c052cf4c9fd221c577b7735bcdca0f..8ab80bafe3f1604f3e05e7287ed5fe4f9ed1e6fb 100644 (file)
@@ -1062,13 +1062,12 @@ static void acpi_add_id(struct acpi_device *device, const char *dev_id)
        if (!id)
                return;
 
-       id->id = kmalloc(strlen(dev_id) + 1, GFP_KERNEL);
+       id->id = kstrdup(dev_id, GFP_KERNEL);
        if (!id->id) {
                kfree(id);
                return;
        }
 
-       strcpy(id->id, dev_id);
        list_add_tail(&id->list, &device->pnp.ids);
 }