summaryrefslogtreecommitdiffstats
path: root/drivers/regulator/of_regulator.c
diff options
context:
space:
mode:
authorStephen Warren <swarren@nvidia.com>2013-01-29 12:01:13 -0700
committerMark Brown <broonie@opensource.wolfsonmicro.com>2013-01-30 10:11:06 +0800
commita2f95c363701deba2205f81929b40222ea6f4f80 (patch)
treed3a2c4e9ceb538ea7d964d68e55ff8e10149cfe8 /drivers/regulator/of_regulator.c
parent949db153b6466c6f7cad5a427ecea94985927311 (diff)
regulator: clear state each invocation of of_regulator_match
of_regulator_match() saves some dynamcially allocated state into the match table that's passed to it. By implementation and not contract, for each match table entry, if non-NULL state is already present, of_regulator_match() will not overwrite it. of_regulator_match() is typically called each time a regulator is probe()d. This means it is called with the same match table over and over again if a regulator triggers deferred probe. This results in stale, kfree()d data being left in the match table from probe to probe, which causes a variety of crashes or use of invalid data. Explicitly free all output state from of_regulator_match() before generating new results in order to avoid this. Signed-off-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Cc: stable@vger.kernel.org
Diffstat (limited to 'drivers/regulator/of_regulator.c')
-rw-r--r--drivers/regulator/of_regulator.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
index 6f684916fd7..66ca769287a 100644
--- a/drivers/regulator/of_regulator.c
+++ b/drivers/regulator/of_regulator.c
@@ -120,6 +120,12 @@ int of_regulator_match(struct device *dev, struct device_node *node,
if (!dev || !node)
return -EINVAL;
+ for (i = 0; i < num_matches; i++) {
+ struct of_regulator_match *match = &matches[i];
+ match->init_data = NULL;
+ match->of_node = NULL;
+ }
+
for_each_child_of_node(node, child) {
name = of_get_property(child,
"regulator-compatible", NULL);