Patch "hwmon: (ltc2992) Avoid division by zero" has been added to the 6.6-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    hwmon: (ltc2992) Avoid division by zero

to the 6.6-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     hwmon-ltc2992-avoid-division-by-zero.patch
and it can be found in the queue-6.6 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit ce1be53347f679a91d3b7ef97206d1ad20c57118
Author: Antoniu Miclaus <antoniu.miclaus@xxxxxxxxxx>
Date:   Wed Oct 11 16:57:53 2023 +0300

    hwmon: (ltc2992) Avoid division by zero
    
    [ Upstream commit 10b02902048737f376104bc69e5212466e65a542 ]
    
    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 <antoniu.miclaus@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20231011135754.13508-1-antoniu.miclaus@xxxxxxxxxx
    Signed-off-by: Guenter Roeck <linux@xxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/hwmon/ltc2992.c b/drivers/hwmon/ltc2992.c
index 589bcd07ce7f7..001799bc28ed6 100644
--- a/drivers/hwmon/ltc2992.c
+++ b/drivers/hwmon/ltc2992.c
@@ -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;




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux