* [PATCH] of/device: Protect against binding of_platform_drivers to non-OF devices
@ 2010-07-22 22:24 Grant Likely
0 siblings, 0 replies; only message in thread
From: Grant Likely @ 2010-07-22 22:24 UTC (permalink / raw)
To: devicetree-discuss, Greg Kroah-Hartman, linux-kernel
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>
---
drivers/of/platform.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 712dfd8..f3f1ec8 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)
pdrv = container_of(pdev->dev.driver, struct platform_driver, driver);
ofpdrv = container_of(pdrv, struct of_platform_driver, platform_driver);
+
+ /* There is an unlikely chance that an of_platform driver might match
+ * on a non-OF platform device. If so, then of_match_device() will
+ * come up empty. Return -EINVAL in this case so other drivers get
+ * the chance to bind. */
match = of_match_device(pdev->dev.driver->of_match_table, &pdev->dev);
- return ofpdrv->probe(pdev, match);
+ return match ? ofpdrv->probe(pdev, match) : -EINVAL;
}
static void platform_driver_shutdown_shim(struct platform_device *pdev)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2010-07-22 22:24 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-22 22:24 [PATCH] of/device: Protect against binding of_platform_drivers to non-OF devices Grant Likely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome