提交 1b8cb929 编写于 作者: P Peter Ujfalusi 提交者: Greg Kroah-Hartman

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: NPeter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 45f035ab
...@@ -103,6 +103,9 @@ struct resource *platform_get_resource_byname(struct platform_device *dev, ...@@ -103,6 +103,9 @@ struct resource *platform_get_resource_byname(struct platform_device *dev,
for (i = 0; i < dev->num_resources; i++) { for (i = 0; i < dev->num_resources; i++) {
struct resource *r = &dev->resource[i]; struct resource *r = &dev->resource[i];
if (unlikely(!r->name))
continue;
if (type == resource_type(r) && !strcmp(r->name, name)) if (type == resource_type(r) && !strcmp(r->name, name))
return r; return r;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册