[PATCH 2/2] regulator: mp886x: fix pontential division by zero

From: Jisheng Zhang

Date: Wed Sep 09 2026 - 13:21:15 EST


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@xxxxxxxxxx>
Closes: https://sashiko.dev/#/patchset/20260901043123.5401-1-jszhang@xxxxxxxxxx?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