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: 2848339 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 865989F271 for ; Thu, 22 Aug 2013 16:33:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E82AA2018D for ; Thu, 22 Aug 2013 16:33:08 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4A9E620182 for ; Thu, 22 Aug 2013 16:33:07 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VCXoC-0004Zg-2y; Thu, 22 Aug 2013 16:32:29 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VCXng-0004ow-OQ; Thu, 22 Aug 2013 16:31:56 +0000 Received: from mail-oa0-f53.google.com ([209.85.219.53]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VCXnd-0004oJ-SG for linux-arm-kernel@lists.infradead.org; Thu, 22 Aug 2013 16:31:54 +0000 Received: by mail-oa0-f53.google.com with SMTP id k18so3954021oag.12 for ; Thu, 22 Aug 2013 09:31:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=S3jkynfN9ra2HHyaYYWOosrjAnDp4B8VbCABOG+Ttxw=; b=nYIRSHsY6W17CTiiJnyP7W7tu9NYyytP3DQMRSDbYIbgQyqbmsoZ7fYM6D19yunsDb AolJbN4w43ZWug0aKav4/cWoaUzhNLT4uQYE85diAEMAN3HCdGEBK0FXdnm06Ns5Arjy bM/7n88+Vkn+nvPxLwV7zmUPvQQPIpTmgQr9LQDNHBvO3Ry3cw7j5sqh+M6niKygphti HOxMOFOYCFjNLfLM9FXBZgR64zIEvIEuQ93slzc9yjrQMLCF5Zt2E2aVq35fdB/iUv3s WbTq1nc4OsXVAqLnAh1CaAJ4QHREitjCu8YSxTE/GKZoPaKRY91dQq5oFzUki7DalF3Y ebjA== X-Gm-Message-State: ALoCoQnMhTNTAt4x6Ij2a/UPvbrtBYjRD7MrkA/ZQxs4SoSmcVUNQCTPSzr5kaBjL8AmJVvKjeuk 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 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130822_123153_941356_196CDA32 X-CRM114-Status: GOOD ( 11.63 ) X-Spam-Score: -2.6 (--) Cc: patches@linaro.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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); }