]>
Commit | Line | Data |
---|---|---|
427cc94b GKH |
1 | From 70b464918e5331e488058870fcc6821d54c4e541 Mon Sep 17 00:00:00 2001 |
2 | From: Steve Twiss <stwiss.opensource@diasemi.com> | |
3 | Date: Mon, 18 Mar 2019 16:17:57 +0000 | |
4 | Subject: regulator: core: fix error path for regulator_set_voltage_unlocked | |
5 | ||
6 | From: Steve Twiss <stwiss.opensource@diasemi.com> | |
7 | ||
8 | commit 70b464918e5331e488058870fcc6821d54c4e541 upstream. | |
9 | ||
10 | During several error paths in the function | |
11 | regulator_set_voltage_unlocked() the value of 'ret' can take on negative | |
12 | error values. However, in calls that go through the 'goto out' statement, | |
13 | this return value is lost and return 0 is used instead, indicating a | |
14 | 'pass'. | |
15 | ||
16 | There are several cases where this function should legitimately return a | |
17 | fail instead of a pass: one such case includes constraints check during | |
18 | voltage selection in the call to regulator_check_voltage(), which can | |
19 | have -EINVAL for the case when an unsupported voltage is incorrectly | |
20 | requested. In that case, -22 is expected as the return value, not 0. | |
21 | ||
22 | Fixes: 9243a195be7a ("regulator: core: Change voltage setting path") | |
23 | Cc: stable <stable@vger.kernel.org> | |
24 | Signed-off-by: Steve Twiss <stwiss.opensource@diasemi.com> | |
25 | Reviewed-by: Dmitry Osipenko <digetx@gmail.com> | |
26 | Signed-off-by: Mark Brown <broonie@kernel.org> | |
27 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
28 | ||
29 | --- | |
30 | drivers/regulator/core.c | 11 ++++------- | |
31 | 1 file changed, 4 insertions(+), 7 deletions(-) | |
32 | ||
33 | --- a/drivers/regulator/core.c | |
34 | +++ b/drivers/regulator/core.c | |
35 | @@ -3360,15 +3360,12 @@ static int regulator_set_voltage_unlocke | |
36 | ||
37 | /* for not coupled regulators this will just set the voltage */ | |
38 | ret = regulator_balance_voltage(rdev, state); | |
39 | - if (ret < 0) | |
40 | - goto out2; | |
41 | + if (ret < 0) { | |
42 | + voltage->min_uV = old_min_uV; | |
43 | + voltage->max_uV = old_max_uV; | |
44 | + } | |
45 | ||
46 | out: | |
47 | - return 0; | |
48 | -out2: | |
49 | - voltage->min_uV = old_min_uV; | |
50 | - voltage->max_uV = old_max_uV; | |
51 | - | |
52 | return ret; | |
53 | } | |
54 |