提交 3ded9104 编写于 作者: R Rafael J. Wysocki

driver core: Avoid NULL pointer dereferences in device_is_bound()

If device_is_bound() is called on a device that's not been registered
yet, it will attepmt to dereference dev->p which is NULL, so avoid
that by checking dev->p in there against NULL.

Fixes: 6b9cb427 "device core: add device_is_bound()"
Reported-and-tested-by: NGuenter Roeck <linux@roeck-us.net>
Tested-by: NTony Lindgren <tony@atomide.com>
Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
上级 2d30bb0b
......@@ -234,7 +234,7 @@ late_initcall(deferred_probe_initcall);
*/
bool device_is_bound(struct device *dev)
{
return klist_node_attached(&dev->p->knode_driver);
return dev->p && klist_node_attached(&dev->p->knode_driver);
}
static void driver_bound(struct device *dev)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册