Patch "power: supply: ip5xxx: Fix integer overflow in current_now calculation" has been added to the 6.0-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

    power: supply: ip5xxx: Fix integer overflow in current_now calculation

to the 6.0-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:
     power-supply-ip5xxx-fix-integer-overflow-in-current_.patch
and it can be found in the queue-6.0 subdirectory.

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



commit 2b16a3b1c9108e9665ae8f6ff1440e499077fbf0
Author: Ondrej Jirman <megi@xxxxxx>
Date:   Sat Oct 29 00:40:52 2022 +0200

    power: supply: ip5xxx: Fix integer overflow in current_now calculation
    
    [ Upstream commit f9be5cb6c1f0191f8bcf4413b7e17e58e8dfaaa1 ]
    
    When current is larger than ~2A, the multiplication in current_now
    property overflows and the kernel reports invalid negative current
    value. Change the numerator and denominator while preserving their
    ratio to allow up to +-6A before the overflow.
    
    Fixes: 75853406fa27 ("power: supply: Add a driver for Injoinic power bank ICs")
    Signed-off-by: Ondrej Jirman <megi@xxxxxx>
    Reviewed-by: Samuel Holland <samuel@xxxxxxxxxxxx>
    [use 149197/200 instead of 261095/350 as suggested by Samuel]
    Signed-off-by: Sebastian Reichel <sebastian.reichel@xxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/power/supply/ip5xxx_power.c b/drivers/power/supply/ip5xxx_power.c
index 218e8e689a3f..00221e9c0bfc 100644
--- a/drivers/power/supply/ip5xxx_power.c
+++ b/drivers/power/supply/ip5xxx_power.c
@@ -352,7 +352,7 @@ static int ip5xxx_battery_get_property(struct power_supply *psy,
 		ret = ip5xxx_battery_read_adc(ip5xxx, IP5XXX_BATIADC_DAT0,
 					      IP5XXX_BATIADC_DAT1, &raw);
 
-		val->intval = DIV_ROUND_CLOSEST(raw * 745985, 1000);
+		val->intval = DIV_ROUND_CLOSEST(raw * 149197, 200);
 		return 0;
 
 	case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT:



[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