Driver core: use kmemdup in platform_device_add_resources
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Tue, 15 Jun 2010 08:47:55 +0000 (10:47 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 5 Aug 2010 20:53:34 +0000 (13:53 -0700)
This makes platform_device_add_resources look like
platform_device_add_data.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/base/platform.c

index 4d99c8bdfedcd8f062c9e7924e0698cf692b81de..26eb69d88eb6e6addcb12590a5a7a7840bd25ad5 100644 (file)
@@ -191,13 +191,13 @@ int platform_device_add_resources(struct platform_device *pdev,
 {
        struct resource *r;
 
-       r = kmalloc(sizeof(struct resource) * num, GFP_KERNEL);
+       r = kmemdup(res, sizeof(struct resource) * num, GFP_KERNEL);
        if (r) {
-               memcpy(r, res, sizeof(struct resource) * num);
                pdev->resource = r;
                pdev->num_resources = num;
+               return 0;
        }
-       return r ? 0 : -ENOMEM;
+       return -ENOMEM;
 }
 EXPORT_SYMBOL_GPL(platform_device_add_resources);