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: 2841928 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6428ABF546 for ; Fri, 9 Aug 2013 13:17:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3F42A20292 for ; Fri, 9 Aug 2013 13:17:01 +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 B3C162028D for ; Fri, 9 Aug 2013 13:16:59 +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 1V7mYj-0004g5-EY; Fri, 09 Aug 2013 13:16:49 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V7mYc-00050S-MX; Fri, 09 Aug 2013 13:16:42 +0000 Received: from mail-ie0-f169.google.com ([209.85.223.169]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V7mYZ-0004yj-Uo for linux-arm-kernel@lists.infradead.org; Fri, 09 Aug 2013 13:16:40 +0000 Received: by mail-ie0-f169.google.com with SMTP id qd12so4195195ieb.28 for ; Fri, 09 Aug 2013 06:16:18 -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:content-type:content-transfer-encoding; bh=S3jkynfN9ra2HHyaYYWOosrjAnDp4B8VbCABOG+Ttxw=; b=bkmFaGQs3IdQjNojz9bqIifhryFWUk7Nnh8kqGiMIAIpKp1wPahuwaKIqMLua8HXIZ UeSJ2JihavanGyy2x6yobJ9S8lmn5t4Nm8o8T1h9mtbiAfdvHsikSqjfrffayBxuRhiy 070M/9FKrwuaa3k5BFM/xmr/+lM1j2Q9XDibGh4BjSNEOJ4/a+6kOGozL9SfSt/F7Z9O AU/ymKAPwpfcTJnEQGhxy2as6XcHIwTCqFOQovR9ntYLzUTVnH1xeQqkYFsPvRKZyv73 zIfh4sCodfO0dXgAKaBaTk29ZAS5PycYsNES57jBmA5yQ3W78oMX8MP9IZNXaoSG+t9a Hzrw== X-Gm-Message-State: ALoCoQmasL7/Pi8Y+kXDFW2d4cBkJ+K6d3egFMS9FIxpeBA+edUaop6D8JVWLfjLQRaytwsryAmU 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 Subject: [PATCH] clk: get matching entry under lock in of_clk_init() X-Enigmail-Version: 1.4.6 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130809_091640_045397_FB07A549 X-CRM114-Status: GOOD ( 12.28 ) X-Spam-Score: -2.6 (--) Cc: mturquette@linaro.org, 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=-4.2 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); }