summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2016-01-12 01:51:44 +0100
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2016-01-12 01:51:44 +0100
commit3ded91041a762423bd49bb932ae2e36b65c6ae4b (patch)
treebc44c929b80788b34ee3b37d4c991ec54145fc8d
parentplatform: Do not detach from PM domains on shutdown (diff)
downloadlinux-3ded91041a762423bd49bb932ae2e36b65c6ae4b.tar.xz
linux-3ded91041a762423bd49bb932ae2e36b65c6ae4b.zip
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: 6b9cb42752da "device core: add device_is_bound()" Reported-and-tested-by: Guenter Roeck <linux@roeck-us.net> Tested-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to '')
-rw-r--r--drivers/base/dd.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 049942176b00..c4da2df62e02 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -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)