]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
regulator: core: fix error path for regulator_set_voltage_unlocked
authorSteve Twiss <stwiss.opensource@diasemi.com>
Mon, 18 Mar 2019 16:17:57 +0000 (16:17 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 25 May 2019 16:21:58 +0000 (18:21 +0200)
commit5b3b51fe5befc703eb218b8f0f71d2c6657c974c
tree63a362f85c8cf9b910d6f47bda18056dbe74946a
parent97346dda2c9952f6e86de509cd9982587011b9b0
regulator: core: fix error path for regulator_set_voltage_unlocked

commit 70b464918e5331e488058870fcc6821d54c4e541 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: 9243a195be7a ("regulator: core: Change voltage setting path")
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Steve Twiss <stwiss.opensource@diasemi.com>
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/regulator/core.c