From patchwork Wed Jul 4 13:15:37 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prashant Gaikwad X-Patchwork-Id: 1156011 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 81B5EDFF0F for ; Wed, 4 Jul 2012 13:19:24 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SmPR2-0000wM-7W; Wed, 04 Jul 2012 13:16:00 +0000 Received: from hqemgate04.nvidia.com ([216.228.121.35]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1SmPQw-0000vJ-Dq for linux-arm-kernel@lists.infradead.org; Wed, 04 Jul 2012 13:15:55 +0000 Received: from hqnvupgp07.nvidia.com (Not Verified[216.228.121.13]) by hqemgate04.nvidia.com id ; Wed, 04 Jul 2012 06:15:03 -0700 Received: from hqemhub02.nvidia.com ([172.17.108.22]) by hqnvupgp07.nvidia.com (PGP Universal service); Wed, 04 Jul 2012 06:12:21 -0700 X-PGP-Universal: processed; by hqnvupgp07.nvidia.com on Wed, 04 Jul 2012 06:12:21 -0700 Received: from localhost.localdomain (172.20.144.16) by hqemhub02.nvidia.com (172.20.150.31) with Microsoft SMTP Server (TLS) id 8.3.264.0; Wed, 4 Jul 2012 06:15:46 -0700 From: Prashant Gaikwad To: Subject: [PATCH] clk: Fix cached parent ptrs allocation Date: Wed, 4 Jul 2012 18:45:37 +0530 Message-ID: <1341407737-1016-1-git-send-email-pgaikwad@nvidia.com> X-Mailer: git-send-email 1.7.4.1 X-NVConfidentiality: public MIME-Version: 1.0 X-Spam-Note: CRM114 invocation failed X-Spam-Score: -6.9 (------) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-6.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [216.228.121.35 listed in list.dnswl.org] -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Prashant Gaikwad , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, swarren@wwwdotorg.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Compiler optimizes code someway that even if clk->parents is not NULL it tries to allocate parents array. Change the condition so that compiler does not optimize it in wrong way. Also, initialize i to num_parents to make sure parent is searched using parent name if parents is NULL. Signed-off-by: Prashant Gaikwad --- Mike, There could be some other way to fix problem. I have not debugged it in detail but I think this simple change should do. drivers/clk/clk.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 026d901..b28f2ae 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -1066,18 +1066,18 @@ static int __clk_set_parent(struct clk *clk, struct clk *parent) struct clk *old_parent; unsigned long flags; int ret = -EINVAL; - u8 i; + u8 i = clk->num_parents; old_parent = clk->parent; /* find index of new parent clock using cached parent ptrs */ - if (clk->parents) + if (!clk->parents) + clk->parents = kzalloc((sizeof(struct clk*) * clk->num_parents), + GFP_KERNEL); + else for (i = 0; i < clk->num_parents; i++) if (clk->parents[i] == parent) break; - else - clk->parents = kzalloc((sizeof(struct clk*) * clk->num_parents), - GFP_KERNEL); /* * find index of new parent clock using string name comparison