From patchwork Fri Aug 9 13:16:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 18915 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f199.google.com (mail-qc0-f199.google.com [209.85.216.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D051925A57 for ; Fri, 9 Aug 2013 13:16:20 +0000 (UTC) Received: by mail-qc0-f199.google.com with SMTP id j10sf5015260qcx.10 for ; Fri, 09 Aug 2013 06:16:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-gm-message-state:delivered-to:message-id:date:from:user-agent :mime-version:to:cc:subject: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=S3jkynfN9ra2HHyaYYWOosrjAnDp4B8VbCABOG+Ttxw=; b=QTU+ASk1ZlO6lYfJUjxd8TC1IInYdkNE3k7sm0TGqnVQWkMH+128pnVJyteDkRpMSO SaAKIP27UydoaltxBMTev524BHdu1yi8t8gcZPohxjC2H1p235cvKp9RQtVAv3IibcQJ Rs+ST20jDkP48Hl4jU7U+8xbzBGgUCh5EMjxVggDO0RwyhRqIayq3ZclaaqzGG46ZAVF LTKKEIIX0k3DM0AK4jPmfvLngRf+2MnaA8dsdDoePkQmW4mr/vtjjz3vUbR1nXn3eK6K 1OYhRt4heKat4zhm1cyfvaF/t/L4LqiVHjlnVfqEokw7kxZWtd1dyG5HDZ4ZdS67C1GT jmMw== X-Received: by 10.236.112.33 with SMTP id x21mr5219151yhg.57.1376054180066; Fri, 09 Aug 2013 06:16:20 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.94.163 with SMTP id dd3ls1462907qeb.92.gmail; Fri, 09 Aug 2013 06:16:19 -0700 (PDT) X-Received: by 10.52.103.35 with SMTP id ft3mr4960993vdb.5.1376054179914; Fri, 09 Aug 2013 06:16:19 -0700 (PDT) Received: from mail-vc0-f170.google.com (mail-vc0-f170.google.com [209.85.220.170]) by mx.google.com with ESMTPS id j19si2629430vcv.103.2013.08.09.06.16.19 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 09 Aug 2013 06:16:19 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.170 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.170; Received: by mail-vc0-f170.google.com with SMTP id kw10so1013788vcb.15 for ; Fri, 09 Aug 2013 06:16:19 -0700 (PDT) X-Gm-Message-State: ALoCoQkDeYFPQ6HT7npPNJ6pH1KLgI3kT1soCWI1b/QfO1OB/2V87EB6aBEVMpl9P6MHBioPrzo4 X-Received: by 10.58.6.210 with SMTP id d18mr306821vea.96.1376054179828; Fri, 09 Aug 2013 06:16:19 -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 u4csp72680vcz; Fri, 9 Aug 2013 06:16:19 -0700 (PDT) X-Received: by 10.42.68.75 with SMTP id w11mr4278261ici.117.1376054178848; Fri, 09 Aug 2013 06:16:18 -0700 (PDT) Received: from mail-ie0-f176.google.com (mail-ie0-f176.google.com [209.85.223.176]) by mx.google.com with ESMTPS id k9si1522725igv.40.2013.08.09.06.16.17 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 09 Aug 2013 06:16:18 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.223.176 is neither permitted nor denied by best guess record for domain of alex.elder@linaro.org) client-ip=209.85.223.176; Received: by mail-ie0-f176.google.com with SMTP id 9so4032308iec.21 for ; Fri, 09 Aug 2013 06:16:17 -0700 (PDT) X-Received: by 10.42.44.4 with SMTP id z4mr4046491ice.84.1376054176989; Fri, 09 Aug 2013 06:16:16 -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 p10sm3500952igx.4.2013.08.09.06.16.15 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 09 Aug 2013 06:16:16 -0700 (PDT) Message-ID: <5204EBA0.1070803@linaro.org> Date: Fri, 09 Aug 2013 08:16:16 -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: linux-arm-kernel@lists.infradead.org CC: mturquette@linaro.org, patches@linaro.org Subject: [PATCH] clk: get matching entry under lock in of_clk_init() X-Enigmail-Version: 1.4.6 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.170 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: , Currently of_clk_init() finds a matching device node while holding the device tree spinlock. When a matching device node is found, the lock is dropped and then re-acquired in order to get a reference to the matching device id structure. Acquiring the spinlock twice is unnecessary (and it opens a vulnerable window that could conceivably lead to errors). There already exists an interface for both finding and taking a reference to a device id under lock, so use it. Signed-off-by: Alex Elder Reviewed-by: Christian Daudt Reviewed-by: Markus Mayer Reviewed-by: Matt Porter --- drivers/clk/clk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 56a00db..760ab1d 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -2116,13 +2116,13 @@ EXPORT_SYMBOL_GPL(of_clk_get_parent_name); */ void __init of_clk_init(const struct of_device_id *matches) { + const struct of_device_id *match; struct device_node *np; if (!matches) matches = __clk_of_table; - for_each_matching_node(np, matches) { - const struct of_device_id *match = of_match_node(matches, np); + for_each_matching_node_and_match(np, matches, &match) { of_clk_init_cb_t clk_init_cb = match->data; clk_init_cb(np); }