]> git.baikalelectronics.ru Git - kernel.git/commit
regulator: clear state each invocation of of_regulator_match
authorStephen Warren <swarren@nvidia.com>
Tue, 29 Jan 2013 19:01:13 +0000 (12:01 -0700)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Wed, 30 Jan 2013 02:11:06 +0000 (10:11 +0800)
commitcfb9afe8cd5d5fd022cbd914861f61fca070ba1a
treed3a2c4e9ceb538ea7d964d68e55ff8e10149cfe8
parent770407bf7f28b6a32c409067a0c6f94c462ff018
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
drivers/regulator/of_regulator.c