]> rtime.felk.cvut.cz Git - can-eth-gw-linux.git/commitdiff
driver core: Check if r->name is valid in platform_get_resource_byname()
authorPeter Ujfalusi <peter.ujfalusi@ti.com>
Thu, 23 Aug 2012 14:10:00 +0000 (17:10 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 6 Sep 2012 20:29:11 +0000 (13:29 -0700)
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 <peter.ujfalusi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/base/platform.c

index 3f8077ce585ca52ea99bf7251b446fb53f1cc7ca..ddeca142293ccbe378f5b5c207465f4e1f5e3056 100644 (file)
@@ -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;
        }