Skip to content

Commit

Permalink
driver core: Avoid NULL pointer dereferences in device_is_bound()
Browse files Browse the repository at this point in the history
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: 6b9cb42 "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>
  • Loading branch information
Rafael J. Wysocki committed Jan 12, 2016
1 parent 2d30bb0 commit 3ded910
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/base/dd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3ded910

Please sign in to comment.