lkml.org 
[lkml]   [2013]   [Feb]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[ 04/61] regulator: clear state each invocation of of_regulator_match
    Date
    3.7-stable review patch.  If anyone has any objections, please let me know.

    ------------------

    From: Stephen Warren <swarren@nvidia.com>

    commit a2f95c363701deba2205f81929b40222ea6f4f80 upstream.

    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>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    ---
    drivers/regulator/of_regulator.c | 6 ++++++
    1 file changed, 6 insertions(+)

    --- a/drivers/regulator/of_regulator.c
    +++ b/drivers/regulator/of_regulator.c
    @@ -120,6 +120,12 @@ int of_regulator_match(struct device *de
    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);



    \
     
     \ /
      Last update: 2013-02-13 03:41    [W:8.767 / U:0.008 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site