From patchwork Thu Aug 22 16:31:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 19424 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f72.google.com (mail-yh0-f72.google.com [209.85.213.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4450D246AD for ; Thu, 22 Aug 2013 16:31:31 +0000 (UTC) Received: by mail-yh0-f72.google.com with SMTP id l109sf1815419yhq.3 for ; Thu, 22 Aug 2013 09:31:30 -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: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=S3jkynfN9ra2HHyaYYWOosrjAnDp4B8VbCABOG+Ttxw=; b=SUnfqPq0q68pyTaGef7KvusxrxOYyTM8gwAxHTxAbWdSr7G9VCN9LRKXW4YhgyToF/ Lf2LuplaUNyQtkVrmPeA/iUuqBaZD7AAlLz2ydrtEjjRtk9/p+KUu/OjxAaCUcZQ5VFN 37H2+eeSoh3NBpTof1Z9sRCFc7GnQHRyRjiIUjwiqXjgiNFgMK0/GjNwofCZ4sPMz7ws O6ih66GZHTjsAX7+Ppm5WIdEjs9i2GzrkUgX0V/3nZ6Ac9DKnY7SlbxwlCn40d55ccZt s6DaD7UgW7NzGI7//gYh4U5Lxi4oa1+PfYGMmfLwjsYQ8HbBkNPF8HhnimcHBWEzTwud fa2A== X-Received: by 10.236.166.35 with SMTP id f23mr4831856yhl.22.1377189090303; Thu, 22 Aug 2013 09:31:30 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.4.41 with SMTP id h9ls1170050qeh.79.gmail; Thu, 22 Aug 2013 09:31:30 -0700 (PDT) X-Received: by 10.58.119.233 with SMTP id kx9mr12213023veb.3.1377189090161; Thu, 22 Aug 2013 09:31:30 -0700 (PDT) Received: from mail-ve0-f170.google.com (mail-ve0-f170.google.com [209.85.128.170]) by mx.google.com with ESMTPS id xz7si4220247vcb.125.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 22 Aug 2013 09:31:30 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.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.128.170; Received: by mail-ve0-f170.google.com with SMTP id 15so1715541vea.15 for ; Thu, 22 Aug 2013 09:31:30 -0700 (PDT) X-Gm-Message-State: ALoCoQl5Ov3AIANhwD3SUzl1Icdab7MWjjyfKqKshcmgfjdf4W7wCXaQR/orXqA125e+YTxjaj8l X-Received: by 10.58.106.82 with SMTP id gs18mr12239955veb.18.1377189090074; Thu, 22 Aug 2013 09:31:30 -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 u4csp40516vcz; Thu, 22 Aug 2013 09:31:29 -0700 (PDT) X-Received: by 10.60.155.166 with SMTP id vx6mr15580990oeb.28.1377189089031; Thu, 22 Aug 2013 09:31:29 -0700 (PDT) Received: from mail-ob0-f173.google.com (mail-ob0-f173.google.com [209.85.214.173]) by mx.google.com with ESMTPS id fk1si4832938oeb.13.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 22 Aug 2013 09:31:29 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.214.173 is neither permitted nor denied by best guess record for domain of alex.elder@linaro.org) client-ip=209.85.214.173; Received: by mail-ob0-f173.google.com with SMTP id ta17so4056067obb.18 for ; Thu, 22 Aug 2013 09:31:28 -0700 (PDT) X-Received: by 10.50.78.130 with SMTP id b2mr6830770igx.41.1377189088618; Thu, 22 Aug 2013 09:31:28 -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 cl4sm1211070igc.1.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 22 Aug 2013 09:31:27 -0700 (PDT) Message-ID: <52163CE3.8000806@linaro.org> Date: Thu, 22 Aug 2013 11:31:31 -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, mturquette@linaro.org CC: patches@linaro.org Subject: [PATCH, resend] clk: get matching entry under lock in of_clk_init() References: <5204EBA0.1070803@linaro.org> In-Reply-To: <5204EBA0.1070803@linaro.org> X-Enigmail-Version: 1.4.6 X-Forwarded-Message-Id: <5204EBA0.1070803@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.128.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); }