drivers/power/da9052-battery.c: avoid out-of-range array access
A message that is not in the archive (sent off-list or not yet received): [email protected]
Anton Vorontsov
AppliedQuoted 5 lines · Nickolai Zeldovich
Avoid accessing vc_tbl_ref[3], which is one past the end of that array, in
da9052_determine_vc_tbl_index(), by adjusting the loop bound.Signed-off-by Nickolai Zeldovich <[email protected]>---
Applied, thanks!
Quoted 18 lines
drivers/power/da9052-battery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/power/da9052-battery.c +1
-1@@ -337,7 +337,7 @@ static unsigned char da9052_determine_vc_tbl_index(unsigned char adc_temp)if (adc_temp > vc_tbl_ref[DA9052_VC_TBL_REF_SZ -1 ])return DA9052_VC_TBL_REF_SZ -1 ; -for (i =0 ; i <DA9052_VC_TBL_REF_SZ ; i++) { +for (i =0 ; i <DA9052_VC_TBL_REF_SZ -1 ; i++) {if ((adc_temp > vc_tbl_ref[i]) && (adc_temp <=DA9052_MEAN (vc_tbl_ref[i], vc_tbl_ref[i +1 ])))return i;Signature · 1 line
1.7.10.4