aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/of
diff options
context:
space:
mode:
authorGrant Likely <grant.likely@secretlab.ca>2010-07-22 12:36:28 -0400
committerGrant Likely <grant.likely@secretlab.ca>2010-07-24 11:57:53 -0400
commitc1b6d380b781b5238989a4bfba02450057670804 (patch)
tree86f0acab0ce296b307150f25ab166191e5c3f6d1 /drivers/of
parent295960429675e17ec658320ebb24385727032bed (diff)
of/device: Protect against binding of_platform_drivers to non-OF devices
There is an unlikely chance of this situation is occurring, but it is easy to protect against. If a matching entry cannot be found in the of_match_table, then don't bind the driver. Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/of')
-rw-r--r--drivers/of/platform.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 712dfd866df0..f3f1ec81ef48 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -30,8 +30,13 @@ static int platform_driver_probe_shim(struct platform_device *pdev)
30 30
31 pdrv = container_of(pdev->dev.driver, struct platform_driver, driver); 31 pdrv = container_of(pdev->dev.driver, struct platform_driver, driver);
32 ofpdrv = container_of(pdrv, struct of_platform_driver, platform_driver); 32 ofpdrv = container_of(pdrv, struct of_platform_driver, platform_driver);
33
34 /* There is an unlikely chance that an of_platform driver might match
35 * on a non-OF platform device. If so, then of_match_device() will
36 * come up empty. Return -EINVAL in this case so other drivers get
37 * the chance to bind. */
33 match = of_match_device(pdev->dev.driver->of_match_table, &pdev->dev); 38 match = of_match_device(pdev->dev.driver->of_match_table, &pdev->dev);
34 return ofpdrv->probe(pdev, match); 39 return match ? ofpdrv->probe(pdev, match) : -EINVAL;
35} 40}
36 41
37static void platform_driver_shutdown_shim(struct platform_device *pdev) 42static void platform_driver_shutdown_shim(struct platform_device *pdev)