]> git.karo-electronics.de Git - linux-beck.git/commitdiff
regulator: core: Add of_node_get to of_regulator_match
authorCharles Keepax <ckeepax@opensource.wolfsonmicro.com>
Thu, 3 Apr 2014 14:32:15 +0000 (15:32 +0100)
committerMark Brown <broonie@linaro.org>
Mon, 14 Apr 2014 16:01:24 +0000 (17:01 +0100)
Currently, of_regulator_match does not increment the reference count of
the of_nodes it takes new references to. This could cause the node
pointer held to be invalid, by the time it is passed to the regulator
core. This patchs adds an of_node_get when we copy each of_node pointer
into the match structure.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
drivers/regulator/of_regulator.c

index ea4f36f2cbe2f1e5432e594711fdb5d4c2c677c6..c58c8d178948aa96a5a6d3d0c607e42d52c8049a 100644 (file)
@@ -119,7 +119,8 @@ EXPORT_SYMBOL_GPL(of_get_regulator_init_data);
  * regulator. The data parsed from a child node will be matched to a regulator
  * based on either the deprecated property regulator-compatible if present,
  * or otherwise the child node's name. Note that the match table is modified
- * in place.
+ * in place and an additional of_node reference is taken for each matched
+ * regulator.
  *
  * Returns the number of matches found or a negative error code on failure.
  */
@@ -162,7 +163,7 @@ int of_regulator_match(struct device *dev, struct device_node *node,
                                        child->name);
                                return -EINVAL;
                        }
-                       match->of_node = child;
+                       match->of_node = of_node_get(child);
                        count++;
                        break;
                }