Patch "power: supply: bq256xx: fix some problem in bq256xx_hw_init" has been added to the 6.7-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: bq256xx: fix some problem in bq256xx_hw_init

to the 6.7-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-bq256xx-fix-some-problem-in-bq256xx_hw_.patch
and it can be found in the queue-6.7 subdirectory.

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



commit dde828779d93ec623d5139e2e8840e4df4f1d74d
Author: Su Hui <suhui@xxxxxxxxxxxx>
Date:   Thu Nov 16 12:18:23 2023 +0800

    power: supply: bq256xx: fix some problem in bq256xx_hw_init
    
    [ Upstream commit b55d073e6501dc6077edaa945a6dad8ac5c8bbab ]
    
    smatch complains that there is a buffer overflow and clang complains
    'ret' is never read.
    
    Smatch error:
    drivers/power/supply/bq256xx_charger.c:1578 bq256xx_hw_init() error:
    buffer overflow 'bq256xx_watchdog_time' 4 <= 4
    
    Clang static checker:
    Value stored to 'ret' is never read.
    
    Add check for buffer overflow and error code from regmap_update_bits().
    
    Fixes: 32e4978bb920 ("power: supply: bq256xx: Introduce the BQ256XX charger driver")
    Signed-off-by: Su Hui <suhui@xxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20231116041822.1378758-1-suhui@xxxxxxxxxxxx
    Signed-off-by: Sebastian Reichel <sebastian.reichel@xxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/power/supply/bq256xx_charger.c b/drivers/power/supply/bq256xx_charger.c
index 789a31bd70c3..1a935bc88510 100644
--- a/drivers/power/supply/bq256xx_charger.c
+++ b/drivers/power/supply/bq256xx_charger.c
@@ -1574,13 +1574,16 @@ static int bq256xx_hw_init(struct bq256xx_device *bq)
 			wd_reg_val = i;
 			break;
 		}
-		if (bq->watchdog_timer > bq256xx_watchdog_time[i] &&
+		if (i + 1 < BQ256XX_NUM_WD_VAL &&
+		    bq->watchdog_timer > bq256xx_watchdog_time[i] &&
 		    bq->watchdog_timer < bq256xx_watchdog_time[i + 1])
 			wd_reg_val = i;
 	}
 	ret = regmap_update_bits(bq->regmap, BQ256XX_CHARGER_CONTROL_1,
 				 BQ256XX_WATCHDOG_MASK, wd_reg_val <<
 						BQ256XX_WDT_BIT_SHIFT);
+	if (ret)
+		return ret;
 
 	ret = power_supply_get_battery_info(bq->charger, &bat_info);
 	if (ret == -ENOMEM)




[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