From: Dmitry Osipenko <digetx@gmail.com>
To: Steve Twiss <stwiss.opensource@diasemi.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Maciej Purski <m.purski@samsubg.com>,
Support Opensource <support.opensource@diasemi.com>
Subject: Re: [PATCH v2] regulator: core: fix error path for regulator_set_voltage_unlocked
Date: Mon, 18 Mar 2019 19:40:55 +0300 [thread overview]
Message-ID: <c3a02cd7-3cd3-b1a5-45fb-278c3391336e@gmail.com> (raw)
In-Reply-To: <20190318163132.1BB633FBA2@swsrvapps-01.diasemi.com>
18.03.2019 19:17, Steve Twiss пишет:
> 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>
> ---
> drivers/regulator/core.c | 11 ++++-------
> 1 file changed, 4 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
> index 68473d0..968dcd9 100644
> --- a/drivers/regulator/core.c
> +++ b/drivers/regulator/core.c
> @@ -3322,15 +3322,12 @@ static int regulator_set_voltage_unlocked(struct regulator *regulator,
>
> /* for not coupled regulators this will just set the voltage */
> ret = regulator_balance_voltage(rdev, state);
> - if (ret < 0)
> - goto out2;
> + if (ret < 0) {
> + voltage->min_uV = old_min_uV;
> + voltage->max_uV = old_max_uV;
> + }
>
> out:
> - return 0;
> -out2:
> - voltage->min_uV = old_min_uV;
> - voltage->max_uV = old_max_uV;
> -
> return ret;
> }
>
>
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
next prev parent reply other threads:[~2019-03-18 16:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-18 16:17 Steve Twiss
2019-03-18 16:40 ` Dmitry Osipenko [this message]
2019-03-18 17:00 ` Steve Twiss
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c3a02cd7-3cd3-b1a5-45fb-278c3391336e@gmail.com \
--to=digetx@gmail.com \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=m.purski@samsubg.com \
--cc=stwiss.opensource@diasemi.com \
--cc=support.opensource@diasemi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®