summaryrefslogtreecommitdiffstats
path: root/drivers/base/dd.c
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2012-05-23 00:09:34 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-06-14 01:40:41 +0200
commit0998d0631001288a5974afc0b2a5f568bcdecb4d (patch)
treec9c6830877b9d39e0233cb29fcd577b947e22fb4 /drivers/base/dd.c
parentW1: split master mutex to avoid deadlocks. (diff)
downloadlinux-0998d0631001288a5974afc0b2a5f568bcdecb4d.tar.xz
linux-0998d0631001288a5974afc0b2a5f568bcdecb4d.zip
device-core: Ensure drvdata = NULL when no driver is bound
1) drvdata is for a driver to store a pointer to driver specific data 2) If no driver is bound, there is no driver specific data associated with the device 3) Thus logically drvdata should be NULL if no driver is bound. But many drivers don't clear drvdata on device_release, or set drvdata early on in probe and leave it set on probe error. Both of which results in a dangling pointer in drvdata. This patch enforce for drvdata to be NULL after device_release or on probe failure. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to '')
-rw-r--r--drivers/base/dd.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 1b1cbb571d38..9a1e9704d782 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -283,6 +283,7 @@ probe_failed:
devres_release_all(dev);
driver_sysfs_remove(dev);
dev->driver = NULL;
+ dev_set_drvdata(dev, NULL);
if (ret == -EPROBE_DEFER) {
/* Driver requested deferred probing */
@@ -487,6 +488,7 @@ static void __device_release_driver(struct device *dev)
drv->remove(dev);
devres_release_all(dev);
dev->driver = NULL;
+ dev_set_drvdata(dev, NULL);
klist_remove(&dev->p->knode_driver);
if (dev->bus)
blocking_notifier_call_chain(&dev->bus->p->bus_notifier,