Skip to content

Commit

Permalink
of/device: Protect against binding of_platform_drivers to non-OF devices
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Grant Likely committed Jul 24, 2010
1 parent 2959604 commit c1b6d38
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion drivers/of/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c1b6d38

Please sign in to comment.