Commit 1b8cb9290671a4c025c16a51d316031f9ec04976

Authored by Peter Ujfalusi
Committed by Greg Kroah-Hartman
1 parent 45f035ab9b

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 <peter.ujfalusi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Showing 1 changed file with 3 additions and 0 deletions Side-by-side Diff

drivers/base/platform.c
... ... @@ -103,6 +103,9 @@
103 103 for (i = 0; i < dev->num_resources; i++) {
104 104 struct resource *r = &dev->resource[i];
105 105  
  106 + if (unlikely(!r->name))
  107 + continue;
  108 +
106 109 if (type == resource_type(r) && !strcmp(r->name, name))
107 110 return r;
108 111 }