aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2012-05-22 18:09:34 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-06-13 19:40:41 -0400
commit0998d0631001288a5974afc0b2a5f568bcdecb4d (patch)
treec9c6830877b9d39e0233cb29fcd577b947e22fb4 /drivers/base
parentb02f8bede217a4b145ecc16d3940c78d83941147 (diff)
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 'drivers/base')
-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:
283 devres_release_all(dev); 283 devres_release_all(dev);
284 driver_sysfs_remove(dev); 284 driver_sysfs_remove(dev);
285 dev->driver = NULL; 285 dev->driver = NULL;
286 dev_set_drvdata(dev, NULL);
286 287
287 if (ret == -EPROBE_DEFER) { 288 if (ret == -EPROBE_DEFER) {
288 /* Driver requested deferred probing */ 289 /* Driver requested deferred probing */
@@ -487,6 +488,7 @@ static void __device_release_driver(struct device *dev)
487 drv->remove(dev); 488 drv->remove(dev);
488 devres_release_all(dev); 489 devres_release_all(dev);
489 dev->driver = NULL; 490 dev->driver = NULL;
491 dev_set_drvdata(dev, NULL);
490 klist_remove(&dev->p->knode_driver); 492 klist_remove(&dev->p->knode_driver);
491 if (dev->bus) 493 if (dev->bus)
492 blocking_notifier_call_chain(&dev->bus->p->bus_notifier, 494 blocking_notifier_call_chain(&dev->bus->p->bus_notifier,