Skip to content

Commit

Permalink
driver core: Check if r->name is valid in platform_get_resource_byname()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Peter Ujfalusi authored and Greg Kroah-Hartman committed Sep 6, 2012
1 parent 45f035a commit 1b8cb92
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/base/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 1b8cb92

Please sign in to comment.