* [PATCH 0/2] regulator: mp886x: fix two issues reported by sashiko
@ 2026-09-09 14:39 Jisheng Zhang
2026-09-09 14:39 ` [PATCH 1/2] regulator: mp886x: check get_voltage_sel() return value Jisheng Zhang
2026-09-09 14:39 ` [PATCH 2/2] regulator: mp886x: fix pontential division by zero Jisheng Zhang
0 siblings, 2 replies; 3+ messages in thread
From: Jisheng Zhang @ 2026-09-09 14:39 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown; +Cc: linux-kernel
Fix two issues reported by sashiko.
https://sashiko.dev/#/patchset/20260901043123.5401-1-jszhang@kernel.org?part=1
Jisheng Zhang (2):
regulator: mp886x: check get_voltage_sel() return value
regulator: mp886x: fix pontential division by zero
drivers/regulator/mp886x.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
--
2.53.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] regulator: mp886x: check get_voltage_sel() return value
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
2026-09-09 14:39 ` [PATCH 2/2] regulator: mp886x: fix pontential division by zero Jisheng Zhang
1 sibling, 0 replies; 3+ messages in thread
From: Jisheng Zhang @ 2026-09-09 14:39 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown; +Cc: linux-kernel
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
^ permalink raw reply [flat|nested] 3+ messages in thread* [PATCH 2/2] regulator: mp886x: fix pontential division by zero
2026-09-09 14:39 [PATCH 0/2] regulator: mp886x: fix two issues reported by sashiko Jisheng Zhang
2026-09-09 14:39 ` [PATCH 1/2] regulator: mp886x: check get_voltage_sel() return value Jisheng Zhang
@ 2026-09-09 14:39 ` Jisheng Zhang
1 sibling, 0 replies; 3+ messages in thread
From: Jisheng Zhang @ 2026-09-09 14:39 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown; +Cc: linux-kernel
If the "mps,fb-voltage-divider" 2nd var is 0, there will be division
by zero bug.
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 | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/regulator/mp886x.c b/drivers/regulator/mp886x.c
index bc25cba33c8b..dda34bf0a74d 100644
--- a/drivers/regulator/mp886x.c
+++ b/drivers/regulator/mp886x.c
@@ -317,6 +317,9 @@ static int mp886x_i2c_probe(struct i2c_client *client)
if (ret)
return ret;
+ if (di->r[1] == 0)
+ return -EINVAL;
+
di->en_gpio = devm_gpiod_get(dev, "enable", GPIOD_OUT_HIGH);
if (IS_ERR(di->en_gpio))
return PTR_ERR(di->en_gpio);
--
2.53.0
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-09 14:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-09 14:39 [PATCH 0/2] regulator: mp886x: fix two issues reported by sashiko Jisheng Zhang
2026-09-09 14:39 ` [PATCH 1/2] regulator: mp886x: check get_voltage_sel() return value Jisheng Zhang
2026-09-09 14:39 ` [PATCH 2/2] regulator: mp886x: fix pontential division by zero Jisheng Zhang
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®