From: Jisheng Zhang <jszhang@kernel.org>
To: Liam Girdwood <lgirdwood@gmail.com>, Mark Brown <broonie@kernel.org>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] regulator: mp886x: check get_voltage_sel() return value
Date: Wed, 9 Sep 2026 22:39:56 +0800 [thread overview]
Message-ID: <20260909143957.9284-2-jszhang@kernel.org> (raw)
In-Reply-To: <20260909143957.9284-1-jszhang@kernel.org>
The get_voltage_sel() can fail, resulting in negative error codes
stored in unsigned integers and corrupted state logic.
Fixes: 97be82880b61 ("regulator: add support for MP8869 regulator")
Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
Closes: https://sashiko.dev/#/patchset/20260901043123.5401-1-jszhang@kernel.org?part=1
---
drivers/regulator/mp886x.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/regulator/mp886x.c b/drivers/regulator/mp886x.c
index e0b62bc02a1e..bc25cba33c8b 100644
--- a/drivers/regulator/mp886x.c
+++ b/drivers/regulator/mp886x.c
@@ -256,6 +256,7 @@ static int mp886x_regulator_register(struct mp886x_device_info *di,
{
struct regulator_desc *rdesc = &di->desc;
struct regulator_dev *rdev;
+ int sel;
rdesc->name = "mp886x-reg";
rdesc->supply_name = "vin";
@@ -277,7 +278,12 @@ static int mp886x_regulator_register(struct mp886x_device_info *di,
rdev = devm_regulator_register(di->dev, &di->desc, config);
if (IS_ERR(rdev))
return PTR_ERR(rdev);
- di->sel = rdesc->ops->get_voltage_sel(rdev);
+
+ sel = rdesc->ops->get_voltage_sel(rdev);
+ if (sel < 0)
+ return sel;
+ di->sel = sel;
+
return 0;
}
--
2.53.0
next prev parent reply other threads:[~2026-09-09 14:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-09 14:39 [PATCH 0/2] regulator: mp886x: fix two issues reported by sashiko Jisheng Zhang
2026-09-09 14:39 ` Jisheng Zhang [this message]
2026-09-09 14:39 ` [PATCH 2/2] regulator: mp886x: fix pontential division by zero Jisheng Zhang
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=20260909143957.9284-2-jszhang@kernel.org \
--to=jszhang@kernel.org \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/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®