Patch "power: supply: adp5061: fix out-of-bounds read in adp5061_get_chg_type()" has been added to the 5.15-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: adp5061: fix out-of-bounds read in adp5061_get_chg_type()

to the 5.15-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-adp5061-fix-out-of-bounds-read-in-adp50.patch
and it can be found in the queue-5.15 subdirectory.

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



commit e64677cfc03dffa85a4ce5d419d6103e9dc7f292
Author: Wei Yongjun <weiyongjun1@xxxxxxxxxx>
Date:   Sat Aug 27 07:32:23 2022 +0000

    power: supply: adp5061: fix out-of-bounds read in adp5061_get_chg_type()
    
    [ Upstream commit 9d47e01b9d807808224347935562f7043a358054 ]
    
    ADP5061_CHG_STATUS_1_CHG_STATUS is masked with 0x07, which means a length
    of 8, but adp5061_chg_type array size is 4, may end up reading 4 elements
    beyond the end of the adp5061_chg_type[] array.
    
    Signed-off-by: Wei Yongjun <weiyongjun1@xxxxxxxxxx>
    Acked-by: Michael Hennerich <michael.hennerich@xxxxxxxxxx>
    Signed-off-by: Sebastian Reichel <sebastian.reichel@xxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/power/supply/adp5061.c b/drivers/power/supply/adp5061.c
index 003557043ab3..daee1161c305 100644
--- a/drivers/power/supply/adp5061.c
+++ b/drivers/power/supply/adp5061.c
@@ -427,11 +427,11 @@ static int adp5061_get_chg_type(struct adp5061_state *st,
 	if (ret < 0)
 		return ret;
 
-	chg_type = adp5061_chg_type[ADP5061_CHG_STATUS_1_CHG_STATUS(status1)];
-	if (chg_type > ADP5061_CHG_FAST_CV)
+	chg_type = ADP5061_CHG_STATUS_1_CHG_STATUS(status1);
+	if (chg_type >= ARRAY_SIZE(adp5061_chg_type))
 		val->intval = POWER_SUPPLY_STATUS_UNKNOWN;
 	else
-		val->intval = chg_type;
+		val->intval = adp5061_chg_type[chg_type];
 
 	return ret;
 }



[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