msm: Fix out of bounds memory access and null pointer checks
CRs-fixed: 313386
Change-Id: I2d3f4c7f0e9ba15aa6ba52530a8c2ccb3d0f7b5d
Signed-off-by: Praveen Chidambaram <pchidamb@codeaurora.org>
diff --git a/arch/arm/mach-msm/pm-8x60.c b/arch/arm/mach-msm/pm-8x60.c
index cb5fcff..8db21f9 100644
--- a/arch/arm/mach-msm/pm-8x60.c
+++ b/arch/arm/mach-msm/pm-8x60.c
@@ -384,6 +384,9 @@
else
i = CONFIG_MSM_IDLE_STATS_BUCKET_COUNT - 1;
+ if (i >= CONFIG_MSM_IDLE_STATS_BUCKET_COUNT)
+ i = CONFIG_MSM_IDLE_STATS_BUCKET_COUNT - 1;
+
stats[id].bucket[i]++;
if (t < stats[id].min_time[i] || !stats[id].max_time[i])