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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



DSP is not supposed to return bad opp_indices which are not part of
the opp table we created for it. If it does, throw an error, and
refuse to switch the OPP.

Ref: discussion: http://marc.info/?t=126395196000002&r=1&w=2
Depends on: http://marc.info/?l=linux-omap&m=126402596424801&w=2

Cc: Ameya Palande <ameya.palande@xxxxxxxxx>
Cc: Deepak Chitriki <deepak.chitriki@xxxxxx>
Cc: Felipe Contreras <felipe.contreras@xxxxxxxxx>
Cc: Hiroshi Doyu <hiroshi.doyu@xxxxxxxxx>
Cc: Omar Ramirez Luna <omar.ramirez@xxxxxx>

Signed-off-by: Nishanth Menon <nm@xxxxxx>
---
 drivers/dsp/bridge/wmd/tiomap3430_pwr.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

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);
-- 
1.6.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Arm (vger)]     [ARM Kernel]     [ARM MSM]     [Linux Tegra]     [Linux WPAN Networking]     [Linux Wireless Networking]     [Maemo Users]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux