From patchwork Sun Oct 20 07:48:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haojian Zhuang X-Patchwork-Id: 21192 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f197.google.com (mail-ie0-f197.google.com [209.85.223.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 47BE5202A2 for ; Sun, 20 Oct 2013 07:49:10 +0000 (UTC) Received: by mail-ie0-f197.google.com with SMTP id e14sf15622765iej.0 for ; Sun, 20 Oct 2013 00:49:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=rmiXiD9GLB202YBie8HdiQuheUkwqFEKu7H9MHcpQxw=; b=MgqeAH0vYF32egbYZocHdankPT0L3K0cybcfH5OdztjJtQ+3FkGGgeIm2WC/zyKwHd y1HZuhaxc8FTlqPYe07YJ9QHcZy0ZKxOsPX2LSmYC6O+Dyewe1US73C5eV1LkGfWHEWA gx1B/iGiVhIzzSQG8yRHy7PwYx+LH8JoUPhIT21P+jPiyGg/6mLDyDBrevwNXn9P3bTv w7SWaTctFrZWWLfGYDiT6l6O4Ba8pD3pBLsFONFmwabpv+sSuL2elvXzbOHgz4OwWHH5 bgyU9g3DOvpcJLm5HvZv9JhUnj9CbkANef5xwI8Ipto5Z08eHCjr8HifJv4Uffnlj5ax L38w== X-Received: by 10.182.111.227 with SMTP id il3mr274891obb.41.1382255350424; Sun, 20 Oct 2013 00:49:10 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.0.41 with SMTP id 9ls1867216qeb.15.gmail; Sun, 20 Oct 2013 00:49:10 -0700 (PDT) X-Received: by 10.220.186.202 with SMTP id ct10mr7438304vcb.14.1382255350284; Sun, 20 Oct 2013 00:49:10 -0700 (PDT) Received: from mail-vb0-f50.google.com (mail-vb0-f50.google.com [209.85.212.50]) by mx.google.com with ESMTPS id na9si3078720vcb.1.2013.10.20.00.49.10 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 20 Oct 2013 00:49:10 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.50 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.50; Received: by mail-vb0-f50.google.com with SMTP id x14so3159999vbb.9 for ; Sun, 20 Oct 2013 00:49:10 -0700 (PDT) X-Gm-Message-State: ALoCoQnCRWv+GjmEcjGGMWRE7LJteMuKCgyW2diP1sQmTuTbdQWGTTJaB0WZ+hoEzDGqriSnuVdO X-Received: by 10.220.105.199 with SMTP id u7mr7159441vco.1.1382255350112; Sun, 20 Oct 2013 00:49:10 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp74103vcz; Sun, 20 Oct 2013 00:49:09 -0700 (PDT) X-Received: by 10.68.109.195 with SMTP id hu3mr929591pbb.123.1382255348939; Sun, 20 Oct 2013 00:49:08 -0700 (PDT) Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id it5si5431271pbc.125.2013.10.20.00.49.08 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 20 Oct 2013 00:49:08 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of haojian.zhuang@linaro.org) client-ip=209.85.160.50; Received: by mail-pb0-f50.google.com with SMTP id uo15so4168981pbc.23 for ; Sun, 20 Oct 2013 00:49:08 -0700 (PDT) X-Received: by 10.68.240.33 with SMTP id vx1mr11796558pbc.12.1382255348111; Sun, 20 Oct 2013 00:49:08 -0700 (PDT) Received: from localhost.localdomain ([61.172.253.150]) by mx.google.com with ESMTPSA id xn12sm16710658pac.12.2013.10.20.00.49.03 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 20 Oct 2013 00:49:07 -0700 (PDT) From: Haojian Zhuang To: linux-kernel@vger.kernel.org, mturquette@linaro.org Cc: patches@linaro.org, Haojian Zhuang Subject: [PATCH] clk: mux: fix the return value of get_parent Date: Sun, 20 Oct 2013 15:48:55 +0800 Message-Id: <1382255335-8131-1-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 1.8.1.2 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: haojian.zhuang@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.50 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , If there're no parents on the clock mux node, it should return 0, not an errnor code. The orphan clock node is using get_parent() to get the index of its parents in__clk_init(). If the return value is negative, it'll be transformed to a u8 value (clk_mux_get_parent()). Then the orphan clock node tries to get its parent with the invalid index. It will only cause accessing memory beyond border. Signed-off-by: Haojian Zhuang --- 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; }