msm: kgsl: Lower bounds check the number of power levels

A misconfigured board file could cause an out-of-bounds
array access through this value.

Change-Id: I64bbad0c096a2efe65376991537d810141370d72
CRs-Fixed: 439230
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
Signed-off-by: Sakshi Agrawal <sakshia@codeaurora.org>
This commit is contained in:
Sakshi Agrawal 2013-01-09 10:41:28 -07:00 committed by Iliyan Malchev
parent 8e426d5e1c
commit a8ad5085a2

View file

@ -878,7 +878,8 @@ int kgsl_pwrctrl_init(struct kgsl_device *device)
if (pdata->set_grp_async != NULL)
pdata->set_grp_async();
if (pdata->num_levels > KGSL_MAX_PWRLEVELS) {
if (pdata->num_levels > KGSL_MAX_PWRLEVELS ||
pdata->num_levels < 1) {
KGSL_PWR_ERR(device, "invalid power level count: %d\n",
pdata->num_levels);
result = -EINVAL;