Skip to content

Commit 565d544

Browse files
amiclausSasha Levin
authored and
Sasha Levin
committed
hwmon: (ltc2992) Avoid division by zero
[ Upstream commit 10b0290 ] Do not allow setting shunt resistor to 0. This results in a division by zero when performing current value computations based on input voltages and connected resistor values. Signed-off-by: Antoniu Miclaus <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 3d76d26 commit 565d544

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

drivers/hwmon/ltc2992.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -875,8 +875,12 @@ static int ltc2992_parse_dt(struct ltc2992_state *st)
875875
}
876876

877877
ret = fwnode_property_read_u32(child, "shunt-resistor-micro-ohms", &val);
878-
if (!ret)
878+
if (!ret) {
879+
if (!val)
880+
return dev_err_probe(&st->client->dev, -EINVAL,
881+
"shunt resistor value cannot be zero\n");
879882
st->r_sense_uohm[addr] = val;
883+
}
880884
}
881885

882886
return 0;

0 commit comments

Comments
 (0)