diff options
author | Nickolai Zeldovich <nickolai@csail.mit.edu> | 2013-01-05 14:14:51 -0500 |
---|---|---|
committer | Anton Vorontsov <anton@enomsg.org> | 2013-01-06 17:34:26 -0500 |
commit | c4f3422630464d231c14c8b9e585c23fcfe3436c (patch) | |
tree | 4aef38e6b144526729768b416ee496bb0699afff /drivers/power/da9052-battery.c | |
parent | 00edfc65c2ce7d039ea45f1b3cc120db01ddcce9 (diff) |
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: Nickolai Zeldovich <nickolai@csail.mit.edu>
Signed-off-by: Anton Vorontsov <anton@enomsg.org>
Diffstat (limited to 'drivers/power/da9052-battery.c')
-rw-r--r-- | drivers/power/da9052-battery.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/power/da9052-battery.c b/drivers/power/da9052-battery.c index 3c5c2e459d73..08193feb3b08 100644 --- a/drivers/power/da9052-battery.c +++ b/drivers/power/da9052-battery.c | |||
@@ -337,7 +337,7 @@ static unsigned char da9052_determine_vc_tbl_index(unsigned char adc_temp) | |||
337 | if (adc_temp > vc_tbl_ref[DA9052_VC_TBL_REF_SZ - 1]) | 337 | if (adc_temp > vc_tbl_ref[DA9052_VC_TBL_REF_SZ - 1]) |
338 | return DA9052_VC_TBL_REF_SZ - 1; | 338 | return DA9052_VC_TBL_REF_SZ - 1; |
339 | 339 | ||
340 | for (i = 0; i < DA9052_VC_TBL_REF_SZ; i++) { | 340 | for (i = 0; i < DA9052_VC_TBL_REF_SZ - 1; i++) { |
341 | if ((adc_temp > vc_tbl_ref[i]) && | 341 | if ((adc_temp > vc_tbl_ref[i]) && |
342 | (adc_temp <= DA9052_MEAN(vc_tbl_ref[i], vc_tbl_ref[i + 1]))) | 342 | (adc_temp <= DA9052_MEAN(vc_tbl_ref[i], vc_tbl_ref[i + 1]))) |
343 | return i; | 343 | return i; |