From patchwork Tue Sep 10 19:29:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 19937 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f71.google.com (mail-vb0-f71.google.com [209.85.212.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 24411246A4 for ; Tue, 10 Sep 2013 19:29:43 +0000 (UTC) Received: by mail-vb0-f71.google.com with SMTP id g17sf9273119vbg.10 for ; Tue, 10 Sep 2013 12:29:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:message-id:date:from:user-agent :mime-version:to:subject:references:in-reply-to:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe:content-type :content-transfer-encoding; bh=fFZ7JYrh7CFY0zWPVVFXI84HJWvJuu3KiDdgPIYwLnA=; b=eKtSqgK+jFJobA54/p8kDFDyPBD1LF8XYn2tfsV6tLGzZfKZMTSoQYGOmhJzBYgjJB dkvm4ReknluYS1sLY43P+yISHs/+7YPR0NKtwZg5h6IpGQDWGkG0tXozLDdQUeqFuylc USNFJua4eI+W2y1osq/dHtoHCSTuMEt8x3rE0pQphAwmaiA9cOCxhHFMAnGvzvFF48DL U8qRxkh6KxRnjmwl8ZbBsLDx7nEMGLi3y4S082Qg9s7cBZvRGEeErf3/buEIJ1anJXOp CrFL+OYooeQ+4jlgNqO05LJ+A//3zME72yKvu0/+RAk1f51V+dv3QSKcVMwiZjyOfnLc 8Sxg== X-Received: by 10.236.207.103 with SMTP id m67mr8900878yho.1.1378841382300; Tue, 10 Sep 2013 12:29:42 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.48.41 with SMTP id i9ls2411084qen.44.gmail; Tue, 10 Sep 2013 12:29:42 -0700 (PDT) X-Received: by 10.52.34.109 with SMTP id y13mr20790705vdi.8.1378841382029; Tue, 10 Sep 2013 12:29:42 -0700 (PDT) Received: from mail-vc0-f177.google.com (mail-vc0-f177.google.com [209.85.220.177]) by mx.google.com with ESMTPS id uh5si4827083vcb.127.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Sep 2013 12:29:42 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.177 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.177; Received: by mail-vc0-f177.google.com with SMTP id gf12so5248596vcb.36 for ; Tue, 10 Sep 2013 12:29:41 -0700 (PDT) X-Gm-Message-State: ALoCoQnwdKv3H9giiCwJRN82tCd5f/Q4ujdv3GSR0Nbk32sBnvyD3JnY+jXcYhEiX5Vpi/njv/T5 X-Received: by 10.58.108.74 with SMTP id hi10mr24870329veb.14.1378841381872; Tue, 10 Sep 2013 12:29:41 -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 u4csp16004vcz; Tue, 10 Sep 2013 12:29:41 -0700 (PDT) X-Received: by 10.236.127.5 with SMTP id c5mr23596769yhi.42.1378841381185; Tue, 10 Sep 2013 12:29:41 -0700 (PDT) Received: from mail-ie0-f172.google.com (mail-ie0-f172.google.com [209.85.223.172]) by mx.google.com with ESMTPS id n22si7285427yha.119.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Sep 2013 12:29:41 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.223.172 is neither permitted nor denied by best guess record for domain of alex.elder@linaro.org) client-ip=209.85.223.172; Received: by mail-ie0-f172.google.com with SMTP id c10so17311555ieb.17 for ; Tue, 10 Sep 2013 12:29:40 -0700 (PDT) X-Received: by 10.50.126.2 with SMTP id mu2mr10981669igb.57.1378841380409; Tue, 10 Sep 2013 12:29:40 -0700 (PDT) Received: from [172.22.22.4] (c-71-195-31-37.hsd1.mn.comcast.net. [71.195.31.37]) by mx.google.com with ESMTPSA id k6sm1903934igx.8.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Sep 2013 12:29:39 -0700 (PDT) Message-ID: <522F732A.3090802@linaro.org> Date: Tue, 10 Sep 2013 14:29:46 -0500 From: Alex Elder User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130804 Thunderbird/17.0.8 MIME-Version: 1.0 To: patches@linaro.org Subject: Fwd: [PATCH] clk: only call get_parent if there is one References: <52288824.1060905@linaro.org> In-Reply-To: <52288824.1060905@linaro.org> X-Enigmail-Version: 1.4.6 X-Forwarded-Message-Id: <52288824.1060905@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: alex.elder@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.177 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: , -------- Original Message -------- Subject: [PATCH] clk: only call get_parent if there is one Date: Thu, 05 Sep 2013 08:33:24 -0500 From: Alex Elder To: Mike Turquette CC: linux-arm-kernel@lists.infradead.org, LKML In __clk_init(), after a clock is mostly initialized, a scan is done of the orphan clocks to see if the clock being registered is the parent of any of them. This code assumes that any clock that provides a get_parent method actually has at least one parent, and that's not a valid assumption. As a result, an orphan clock with no parent can return *something* as the parent index, and that value is blindly used to dereference the orphan's parent_names[] array (which will be ZERO_SIZE_PTR or NULL). Fix this by ensuring get_parent is only called for orphans with at least one parent. Signed-off-by: Alex Elder --- drivers/clk/clk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 54a191c..ea8ff15 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -1628,7 +1628,7 @@ int __clk_init(struct device *dev, struct clk *clk) * this clock */ hlist_for_each_entry_safe(orphan, tmp2, &clk_orphan_list, child_node) { - if (orphan->ops->get_parent) { + if (orphan->num_parents && orphan->ops->get_parent) { i = orphan->ops->get_parent(orphan->hw); if (!strcmp(clk->name, orphan->parent_names[i])) __clk_reparent(orphan, clk);