提交 c4f34226 编写于 作者: N Nickolai Zeldovich 提交者: Anton Vorontsov

da9052-battery: Avoid out-of-range array access

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.

(Hint: there is 'i + 1' inside the loop.)
Signed-off-by: NNickolai Zeldovich <nickolai@csail.mit.edu>
Signed-off-by: NAnton Vorontsov <anton@enomsg.org>
上级 00edfc65
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册