From patchwork Mon Oct 21 08:59:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Russ Dill X-Patchwork-Id: 3075541 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 10A4B9F372 for ; Mon, 21 Oct 2013 09:00:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 71FD32031A for ; Mon, 21 Oct 2013 09:00:43 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4674820334 for ; Mon, 21 Oct 2013 09:00:41 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VYBLm-00029f-8S; Mon, 21 Oct 2013 09:00:34 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VYBLk-0005IO-01; Mon, 21 Oct 2013 09:00:32 +0000 Received: from mail-we0-x22f.google.com ([2a00:1450:400c:c03::22f]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VYBLg-0005Hj-5M for linux-arm-kernel@lists.infradead.org; Mon, 21 Oct 2013 09:00:29 +0000 Received: by mail-we0-f175.google.com with SMTP id t61so6265996wes.34 for ; Mon, 21 Oct 2013 02:00:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id; bh=A73OqxLe+o9h82ueJn7RWayJtTRYfTAPcCEAix4+yfE=; b=dKHuv0tB35e0BNIyKuZ9VUgyFyjDJ+AOskPwJo+NcY8/UvrOjiO911hD++u32gWQIL cbV3Oiof2WBeMUvCIyZ5INyOyEMOEJMBDgFpH7w1pX0c7KORQW8OvXDgS8eFRnVEtsvG 0qHG6Abp7n+EwAQCpPCXk/AwQSvKRb8c9YmIpZ/SFM4EnkCatxKbK20/9to6LU+0zm3t wqEppi2Mj1xiymh3wUlxdpicZ8Z3DDD8YY7h9bvX4CENdVBX6EjWiQoMSVyDhwR3m5Z2 0rGDWQQf8CefrqU8/MG9Osxo8ZHrVzZL+5Yn1GSyzmma1X5ZlUET4XrWBxnQw7vw/eKE Cmrw== X-Received: by 10.180.73.40 with SMTP id i8mr8770196wiv.37.1382346004485; Mon, 21 Oct 2013 02:00:04 -0700 (PDT) Received: from localhost (92.40.248.130.threembb.co.uk. [92.40.248.130]) by mx.google.com with ESMTPSA id ey4sm29987768wic.11.2013.10.21.02.00.01 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 21 Oct 2013 02:00:03 -0700 (PDT) From: Russ Dill To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] clk: mux: Return a sane value on error Date: Mon, 21 Oct 2013 09:59:50 +0100 Message-Id: <1382345990-20623-1-git-send-email-Russ.Dill@ti.com> X-Mailer: git-send-email 1.8.3.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131021_050028_351913_0CC74A10 X-CRM114-Status: GOOD ( 11.48 ) X-Spam-Score: -1.9 (-) Cc: Russ Dill , Mike Turquette , linux-kernel@vger.kernel.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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; }