Commit 4c0642c4 authored by Steve Twiss's avatar Steve Twiss Committed by Greg Kroah-Hartman

regulator: core: fix error path for regulator_set_voltage_unlocked

commit 70b46491 upstream.

During several error paths in the function
regulator_set_voltage_unlocked() the value of 'ret' can take on negative
error values. However, in calls that go through the 'goto out' statement,
this return value is lost and return 0 is used instead, indicating a
'pass'.

There are several cases where this function should legitimately return a
fail instead of a pass: one such case includes constraints check during
voltage selection in the call to regulator_check_voltage(), which can
have -EINVAL for the case when an unsupported voltage is incorrectly
requested. In that case, -22 is expected as the return value, not 0.

Fixes: 9243a195 ("regulator: core: Change voltage setting path")
Cc: stable <stable@vger.kernel.org>
Signed-off-by: default avatarSteve Twiss <stwiss.opensource@diasemi.com>
Reviewed-by: default avatarDmitry Osipenko <digetx@gmail.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 94ba80af
...@@ -3322,15 +3322,12 @@ static int regulator_set_voltage_unlocked(struct regulator *regulator, ...@@ -3322,15 +3322,12 @@ static int regulator_set_voltage_unlocked(struct regulator *regulator,
/* for not coupled regulators this will just set the voltage */ /* for not coupled regulators this will just set the voltage */
ret = regulator_balance_voltage(rdev, state); ret = regulator_balance_voltage(rdev, state);
if (ret < 0) if (ret < 0) {
goto out2; voltage->min_uV = old_min_uV;
voltage->max_uV = old_max_uV;
}
out: out:
return 0;
out2:
voltage->min_uV = old_min_uV;
voltage->max_uV = old_max_uV;
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment