Skip to content

Commit

Permalink
Driver Core: don't oops with unregistered driver in driver_find_device()
Browse files Browse the repository at this point in the history
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.

In [PATCHv5 2/3] ARM: tegra: Add SMMU enabler in AHB:
  http://article.gmane.org/gmane.linux.ports.tegra/4658

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

For more SMMU/AHB specific discussion, refer to the following thread:
  https://lkml.org/lkml/2012/5/10/21

Signed-off-by: Hiroshi DOYU <hdoyu@nvidia.com>
Cc: Stephen Warren <swarren@wwwdotorg.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Hiroshi DOYU authored and Greg Kroah-Hartman committed May 14, 2012
1 parent 3ce9a7c commit 094e47e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/base/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 094e47e

Please sign in to comment.