From patchwork Wed Oct 23 10:17:28 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sunshaojie X-Patchwork-Id: 21226 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f197.google.com (mail-pd0-f197.google.com [209.85.192.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6CF2623903 for ; Wed, 23 Oct 2013 10:17:53 +0000 (UTC) Received: by mail-pd0-f197.google.com with SMTP id q10sf662942pdj.8 for ; Wed, 23 Oct 2013 03:17:52 -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=hkDwVvkVCip4Oa+mKkJXotWWvR7kR3v6APMTsMUvdbU=; b=A6DHZ9F7HmUfCD0wrN6tvSk1SbHobnLnwS8tci5Y4aIyYgjZHnIhFdX3WevgSL7//q E2//4SaUsTIriAkF2R6ACnHTEEB/FOxxjKxNfCI5n54gN2c0TaNc+pQYugtheczCCVKe l6Lxyxcb9ont8a+6ATR/RYC0DC/SPWg1VcIqzYTHH6TDDqn4PvniN63EFqZuQzCZMO4j gEbqDiukBjDWeppXUzjNEHrD6ZqUCKpVe/16rfV05dVFN6HsP2DI/kbC8yROsDrGaFC3 6O2XIUmbAGkQvCm/8gbmQn9Q/GqLNGomILJAq+fONnzQ9P4u77bfAu5gTTlG3HsfOK+2 yp5w== X-Received: by 10.66.121.194 with SMTP id lm2mr925425pab.20.1382523472333; Wed, 23 Oct 2013 03:17:52 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.29.229 with SMTP id n5ls434980qeh.73.gmail; Wed, 23 Oct 2013 03:17:52 -0700 (PDT) X-Received: by 10.52.243.138 with SMTP id wy10mr428874vdc.2.1382523472173; Wed, 23 Oct 2013 03:17:52 -0700 (PDT) Received: from mail-vc0-f169.google.com (mail-vc0-f169.google.com [209.85.220.169]) by mx.google.com with ESMTPS id jb3si7023719vdb.79.2013.10.23.03.17.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 23 Oct 2013 03:17:52 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.169 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.169; Received: by mail-vc0-f169.google.com with SMTP id hu8so317991vcb.0 for ; Wed, 23 Oct 2013 03:17:52 -0700 (PDT) X-Gm-Message-State: ALoCoQm1m6dcojrUxwmt+El/fez3SADhcxA7iHy6ouR1lX4OIY+N8YOCq33uqCuFYZkOw8lR703I X-Received: by 10.52.98.194 with SMTP id ek2mr399801vdb.11.1382523472038; Wed, 23 Oct 2013 03:17:52 -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 u4csp298934vcz; Wed, 23 Oct 2013 03:17:51 -0700 (PDT) X-Received: by 10.68.169.161 with SMTP id af1mr897033pbc.22.1382523471039; Wed, 23 Oct 2013 03:17:51 -0700 (PDT) Received: from mail-pb0-f42.google.com (mail-pb0-f42.google.com [209.85.160.42]) by mx.google.com with ESMTPS id ei3si1575198pbc.200.2013.10.23.03.17.50 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 23 Oct 2013 03:17:51 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.42 is neither permitted nor denied by best guess record for domain of shaojie.sun@linaro.org) client-ip=209.85.160.42; Received: by mail-pb0-f42.google.com with SMTP id jt11so604364pbb.1 for ; Wed, 23 Oct 2013 03:17:50 -0700 (PDT) X-Received: by 10.66.136.71 with SMTP id py7mr2543971pab.2.1382523470632; Wed, 23 Oct 2013 03:17:50 -0700 (PDT) Received: from localhost.localdomain ([58.251.159.202]) by mx.google.com with ESMTPSA id at4sm3494914pbc.30.2013.10.23.03.17.46 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 23 Oct 2013 03:17:49 -0700 (PDT) From: Shaojie Sun To: mike.turquette@linaro.org Cc: private-pmwg@linaro.org, patches@linaro.org, sunshaojie@huawei.com, Shaojie Sun Subject: [PATCH LINUX-CCF] clk: must judge get_parent function return value in __clk_init. Date: Wed, 23 Oct 2013 18:17:28 +0800 Message-Id: <1382523448-29461-1-git-send-email-shaojie.sun@linaro.com> X-Mailer: git-send-email 1.7.9.5 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: shaojie.sun@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.169 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: , For get_parent function may be return a below zero value to indicate that it could function a right value. In this condition orphan->parent_names[i] will lead system a access an unknown memory. Signed-off-by: Shaojie Sun --- drivers/clk/clk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 1144e8c..fcb5c85 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -1632,7 +1632,8 @@ int __clk_init(struct device *dev, struct clk *clk) hlist_for_each_entry_safe(orphan, tmp2, &clk_orphan_list, child_node) { if (orphan->ops->get_parent) { i = orphan->ops->get_parent(orphan->hw); - if (!strcmp(clk->name, orphan->parent_names[i])) + if ((i >= 0) + && !strcmp(clk->name, orphan->parent_names[i])) __clk_reparent(orphan, clk); continue; }