diff mbox

[2/2] DSPBRIDGE: sanitize opp_idx before passing to PM

Message ID 1264052710-30337-3-git-send-email-nm@ti.com (mailing list archive)
State Under Review, archived
Delegated to:
Headers show

Commit Message

Nishanth Menon Jan. 21, 2010, 5:45 a.m. UTC
None
diff mbox

Patch

diff --git a/drivers/dsp/bridge/wmd/tiomap3430_pwr.c b/drivers/dsp/bridge/wmd/tiomap3430_pwr.c
index 5dfbef8..a13e035 100644
--- a/drivers/dsp/bridge/wmd/tiomap3430_pwr.c
+++ b/drivers/dsp/bridge/wmd/tiomap3430_pwr.c
@@ -73,6 +73,12 @@  DSP_STATUS handle_constraints_set(struct WMD_DEV_CONTEXT *pDevContext,
 	/* pick up the opp index */
 	opp_idx = *(((u32 *)(pArgs)) + 1);
 
+	/* Sanity check to ensure things are fine */
+	if (!opp_idx || (opp_idx > pdata->dsp_num_speeds)) {
+		pr_err("%s: DSP requested for an invalid OPP %d Vs %d->%d!\n",
+			__func__, opp_idx, 1, pdata->dsp_num_speeds);
+		return DSP_EINVALIDARG;
+	}
 	/* Read the target value requested by DSP  */
 	DBG_Trace(DBG_LEVEL7, "handle_constraints_set:"
 		"opp requested = 0x%x\n", opp_idx);