Skip to contentSkip to conversation

regulator: mp886x: fix two issues reported by sashiko

PATCH In review Jisheng Zhang 2 participants 4 messages Sep 9 – Sep 23 Voltage and current regulator framework

lore
Share & tools
lore
#0 lore raw

cover regulator: mp886x: fix two issues reported by sashiko

Fix two issues reported by sashiko.
https://sashiko.dev/#/patchset/[email protected]?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(-)
Signature · 1 line
2.53.0
#1 lore raw

PATCH 1/2 regulator: mp886x: check get_voltage_sel() return value

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")
---
 drivers/regulator/mp886x.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/regulator/mp886x.c +7 -1
index e0b62bc02a1e..bc25cba33c8b 100644
@@ -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;
 }
 
Signature · 1 line
2.53.0
#2 lore raw

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

In reply to Jisheng Zhang

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")
---
 drivers/regulator/mp886x.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/regulator/mp886x.c +3 -0
index bc25cba33c8b..dda34bf0a74d 100644
@@ -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);
Signature · 1 line
2.53.0
maintainer
#3 lore raw
In reply to Jisheng Zhang
Quoted 10 lines · Jisheng Zhang

regulator: mp886x: fix two issues reported by sashiko

Fix two issues reported by sashiko.
https://sashiko.dev/#/patchset/[email protected]?part=1

Jisheng Zhang (2):
regulator: mp886x: check get_voltage_sel() return value
regulator: mp886x: fix pontential division by zero

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-7.4

Thanks!

[1/2] regulator: mp886x: check get_voltage_sel() return value

      https://git.kernel.org/broonie/regulator/c/87121c42fadc

[2/2] regulator: mp886x: fix pontential division by zero
https://git.kernel.org/broonie/regulator/c/d16ef5debccc

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark