[PATCH 1/1] Driver Core: don't oops with unregistered driver indriver_find_device()

From: Hiroshi DOYU
Date: Wed May 09 2012 - 07:21:03 EST

driver_find_device() can be called with an unregistered driver. Need
to check driver_private to see if it's populated or not, especially
under deferrable probe.

In the case that there are 2 drivers, one depends on the other. With
-EPROBE_DEFER, two drivers can use deferred probe to ensure that their
relative probe order doesn't matter. If dependee driver is probed
first, then the dependant's driver_find_device('dependee')
succeeds. If the dependant is probed first, then the dependant's
driver_find_device('dependee') should return NULL, and the dependant
should get -EPROBE_DEFER. driver_find_device() needs to return NULL if
it's not populated.

Signed-off-by: Hiroshi DOYU <hdoyu@xxxxxxxxxx>
In [PATCHv5 2/3] ARM: tegra: Add SMMU enabler in AHB:

"tegra_ahb_driver" may not be populated when it's called.

For more SMMU/AHB specific discussion, refer to the following thread:
drivers/base/driver.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 3ec3896..207c27d 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -80,7 +80,7 @@ struct device *driver_find_device(struct device_driver *drv,
struct klist_iter i;
struct device *dev;

- if (!drv)
+ if (!drv || !drv->p)
return NULL;

klist_iter_init_node(&drv->p->klist_devices, &i,

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/