mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Russ Dill <Russ.Dill@ti.com>
To: linux-arm-kernel@lists.infradead.org
Cc: Mike Turquette <mturquette@linaro.org>,
	linux-kernel@vger.kernel.org, Russ Dill <Russ.Dill@ti.com>
Subject: [PATCH] clk: mux: Return a sane value on error
Date: Mon, 21 Oct 2013 09:59:50 +0100	[thread overview]
Message-ID: <1382345990-20623-1-git-send-email-Russ.Dill@ti.com> (raw)

The get_parent op is defined as returning u8, but clk-mux is
returning negative values on error.  Code within drivers/clk/clk.c
uses this return value as an index into an array which could
cause an oops.

Signed-off-by: Russ Dill <Russ.Dill@ti.com>
---
 drivers/clk/clk-mux.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/clk-mux.c b/drivers/clk/clk-mux.c
index 4f96ff3..cc06015 100644
--- a/drivers/clk/clk-mux.c
+++ b/drivers/clk/clk-mux.c
@@ -51,7 +51,7 @@ static u8 clk_mux_get_parent(struct clk_hw *hw)
 		for (i = 0; i < num_parents; i++)
 			if (mux->table[i] == val)
 				return i;
-		return -EINVAL;
+		return 0;
 	}
 
 	if (val && (mux->flags & CLK_MUX_INDEX_BIT))
@@ -61,7 +61,7 @@ static u8 clk_mux_get_parent(struct clk_hw *hw)
 		val--;
 
 	if (val >= num_parents)
-		return -EINVAL;
+		return 0;
 
 	return val;
 }
-- 
1.8.3.2


             reply	other threads:[~2013-10-21  9:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-21  8:59 Russ Dill [this message]
2013-10-30 19:47 ` Mike Turquette

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=1382345990-20623-1-git-send-email-Russ.Dill@ti.com \
    --to=russ.dill@ti.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mturquette@linaro.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®