All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nishanth Menon <nm@ti.com>
To: linux-omap <linux-omap@vger.kernel.org>
Cc: Nishanth Menon <nm@ti.com>,
	Ameya Palande <ameya.palande@nokia.com>,
	Deepak Chitriki <deepak.chitriki@ti.com>,
	Felipe Contreras <felipe.contreras@nokia.com>,
	Hiroshi Doyu <hiroshi.doyu@nokia.com>,
	Omar Ramirez Luna <omar.ramirez@ti.com>
Subject: [PATCH 2/2] DSPBRIDGE: sanitize opp_idx before passing to PM
Date: Wed, 20 Jan 2010 23:45:10 -0600	[thread overview]
Message-ID: <1264052710-30337-3-git-send-email-nm@ti.com> (raw)
In-Reply-To: <1264052710-30337-2-git-send-email-nm@ti.com>

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@nokia.com>
Cc: Deepak Chitriki <deepak.chitriki@ti.com>
Cc: Felipe Contreras <felipe.contreras@nokia.com>
Cc: Hiroshi Doyu <hiroshi.doyu@nokia.com>
Cc: Omar Ramirez Luna <omar.ramirez@ti.com>

Signed-off-by: Nishanth Menon <nm@ti.com>
---
 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


      reply	other threads:[~2010-01-21  5:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <[PATCH 1/2] DSPBRIDGE: remove dependency of mpu freq>
2010-01-21  5:45 ` [PATCH 0/2] DSPBRIDGE: trivial opp constraint Nishanth Menon
2010-01-21  5:45   ` [PATCH 1/2] DSPBRIDGE: improve constraint_value handling Nishanth Menon
2010-01-21  5:45     ` Nishanth Menon [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1264052710-30337-3-git-send-email-nm@ti.com \
    --to=nm@ti.com \
    --cc=ameya.palande@nokia.com \
    --cc=deepak.chitriki@ti.com \
    --cc=felipe.contreras@nokia.com \
    --cc=hiroshi.doyu@nokia.com \
    --cc=linux-omap@vger.kernel.org \
    --cc=omar.ramirez@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.