]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/5.1.5/regulator-core-fix-error-path-for-regulator_set_voltage_unlocked.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 5.1.5 / regulator-core-fix-error-path-for-regulator_set_voltage_unlocked.patch
CommitLineData
b32881e5
GKH
1From 70b464918e5331e488058870fcc6821d54c4e541 Mon Sep 17 00:00:00 2001
2From: Steve Twiss <stwiss.opensource@diasemi.com>
3Date: Mon, 18 Mar 2019 16:17:57 +0000
4Subject: regulator: core: fix error path for regulator_set_voltage_unlocked
5
6From: Steve Twiss <stwiss.opensource@diasemi.com>
7
8commit 70b464918e5331e488058870fcc6821d54c4e541 upstream.
9
10During several error paths in the function
11regulator_set_voltage_unlocked() the value of 'ret' can take on negative
12error values. However, in calls that go through the 'goto out' statement,
13this return value is lost and return 0 is used instead, indicating a
14'pass'.
15
16There are several cases where this function should legitimately return a
17fail instead of a pass: one such case includes constraints check during
18voltage selection in the call to regulator_check_voltage(), which can
19have -EINVAL for the case when an unsupported voltage is incorrectly
20requested. In that case, -22 is expected as the return value, not 0.
21
22Fixes: 9243a195be7a ("regulator: core: Change voltage setting path")
23Cc: stable <stable@vger.kernel.org>
24Signed-off-by: Steve Twiss <stwiss.opensource@diasemi.com>
25Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
26Signed-off-by: Mark Brown <broonie@kernel.org>
27Signed-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@@ -3322,15 +3322,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