From: Rafael J. Wysocki Date: Tue, 12 Jan 2016 00:51:44 +0000 (+0100) Subject: driver core: Avoid NULL pointer dereferences in device_is_bound() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=3ded91041a762423bd49bb932ae2e36b65c6ae4b;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git 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 Tested-by: Tony Lindgren Signed-off-by: Rafael J. Wysocki --- 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)