From 1b8cb9290671a4c025c16a51d316031f9ec04976 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Thu, 23 Aug 2012 17:10:00 +0300 Subject: driver core: Check if r->name is valid in platform_get_resource_byname() Safety check for the validity of the resource name before calling strcmp(). If the resource name is NULL do not compare it, just skip it. Signed-off-by: Peter Ujfalusi Signed-off-by: Greg Kroah-Hartman --- drivers/base/platform.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/base/platform.c') diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 3f8077ce585c..ddeca142293c 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -103,6 +103,9 @@ struct resource *platform_get_resource_byname(struct platform_device *dev, for (i = 0; i < dev->num_resources; i++) { struct resource *r = &dev->resource[i]; + if (unlikely(!r->name)) + continue; + if (type == resource_type(r) && !strcmp(r->name, name)) return r; } -- cgit v1.2.3