drivers: hwmon: ltc2992: avoid division by zero
PATCH 1/1 drivers: hwmon: ltc2992: avoid division by zero
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]>
--- drivers/hwmon/ltc2992.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/hwmon/ltc2992.c +5 -1
@@ -875,8 +875,12 @@ static int ltc2992_parse_dt(struct ltc2992_state *st) } ret =fwnode_property_read_u32 (child,"shunt-resistor-micro-ohms" , &val); -if (!ret) +if (!ret) { +if (!val) +return dev_err_probe (&st->client->dev, -EINVAL , +"shunt resistor value cannot be zero\n" ); st->r_sense_uohm[addr] = val; + } }return 0 ;
Signature · 1 line
2.42.0
Quoted 5 lines · Antoniu Miclaus
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]>
Applied. Please note that the subject should not include "drivers:".
Guenter