From: Uwe Kleine-König Date: Wed, 20 Apr 2011 07:44:44 +0000 (+0200) Subject: driver core/platform_device_add_resources: set resource to NULL if !res X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=cea896238fbfdbce254f51fc8fd78c59df50081f;p=linux-beck.git driver core/platform_device_add_resources: set resource to NULL if !res This makes the res = NULL case more consistant to the res != NULL case as now both overwrite pdev->resource. Reviewed-by: Viresh Kumar Signed-off-by: Uwe Kleine-König Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 58ad8e8ad7a3..667f282f8b7b 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -192,18 +192,17 @@ EXPORT_SYMBOL_GPL(platform_device_alloc); int platform_device_add_resources(struct platform_device *pdev, const struct resource *res, unsigned int num) { - struct resource *r; + struct resource *r = NULL; - if (!res) - return 0; - - r = kmemdup(res, sizeof(struct resource) * num, GFP_KERNEL); - if (r) { - pdev->resource = r; - pdev->num_resources = num; - return 0; + if (res) { + r = kmemdup(res, sizeof(struct resource) * num, GFP_KERNEL); + if (!r) + return -ENOMEM; } - return -ENOMEM; + + pdev->resource = r; + pdev->num_resources = num; + return 0; } EXPORT_SYMBOL_GPL(platform_device_add_resources);