From patchwork Mon Oct 12 13:48:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 54757 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by patches.linaro.org (Postfix) with ESMTPS id 964B022DB6 for ; Mon, 12 Oct 2015 13:50:29 +0000 (UTC) Received: by wibzt1 with SMTP id zt1sf15618480wib.0 for ; Mon, 12 Oct 2015 06:50:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:cc:mime-version:content-type :content-transfer-encoding:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list; bh=hLFtW/D2cvY5+MeIQtzjZoKCEvuPUCt2pfisHfQ1wSs=; b=kTr61vPnUpAfruAs+UPABsdRd/kO98T1OvkEaauxcTtlIoEmbNZraQTPZ3KyiQcxIK hL5mAfxZ9Oud3Q9diFJVY5CtbY+EDVbjePf3dBPo7Ai/kAf5zAA6SGvrCjqg06nmUGMW MYjh8yTuaBJCbPAYfONpib5qpf8NBibIVnbgQ3elRnFwp+tVT0bbRYb+l1qNJAkrVC5w qHRyUvwJFhlR6IIgQgPckXx5Gr9vbVt+gRl9kh0XnFrWYeaZFkm8mrHtepMR//1Yzmm4 kMystAmuUgK8fKBpImEV7a/jyd4CbSplmq4RT6VnUHI8kGNGadurU1DIWHa39iclQMSl TV1w== X-Gm-Message-State: ALoCoQlEWMs8/dou18oE54pxngrKF+pB/YsstARw7g5dTs0KSELOkxoneIm5/Snh7BJ6XeXrwY4W X-Received: by 10.112.72.39 with SMTP id a7mr2013389lbv.1.1444657828906; Mon, 12 Oct 2015 06:50:28 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.43.135 with SMTP id r129ls546137lfr.93.gmail; Mon, 12 Oct 2015 06:50:28 -0700 (PDT) X-Received: by 10.112.173.198 with SMTP id bm6mr12405506lbc.43.1444657828728; Mon, 12 Oct 2015 06:50:28 -0700 (PDT) Received: from mail-lb0-f174.google.com (mail-lb0-f174.google.com. [209.85.217.174]) by mx.google.com with ESMTPS id r134si11314705lfd.0.2015.10.12.06.50.28 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Oct 2015 06:50:28 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) client-ip=209.85.217.174; Received: by lbbk10 with SMTP id k10so31413692lbb.0 for ; Mon, 12 Oct 2015 06:50:28 -0700 (PDT) X-Received: by 10.112.64.72 with SMTP id m8mr12155346lbs.41.1444657828560; Mon, 12 Oct 2015 06:50:28 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp1561092lbq; Mon, 12 Oct 2015 06:50:25 -0700 (PDT) X-Received: by 10.107.16.158 with SMTP id 30mr28021761ioq.50.1444657824509; Mon, 12 Oct 2015 06:50:24 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [198.137.202.9]) by mx.google.com with ESMTPS id a192si1524712ioa.87.2015.10.12.06.50.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Oct 2015 06:50:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 198.137.202.9 as permitted sender) client-ip=198.137.202.9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZldTS-000139-MN; Mon, 12 Oct 2015 13:49:10 +0000 Received: from cam-admin0.cambridge.arm.com ([217.140.96.50]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZldTN-0000m6-IF for linux-arm-kernel@lists.infradead.org; Mon, 12 Oct 2015 13:49:07 +0000 Received: from edgewater-inn.cambridge.arm.com (edgewater-inn.cambridge.arm.com [10.1.203.122]) by cam-admin0.cambridge.arm.com (8.12.6/8.12.6) with ESMTP id t9CDmbWr024772; Mon, 12 Oct 2015 14:48:37 +0100 (BST) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id CB44A1AE33D5; Mon, 12 Oct 2015 14:48:40 +0100 (BST) From: Will Deacon To: arm@kernel.org Subject: [PATCH RESEND] drivers/perf: arm_pmu: avoid CPU device_node reference leak Date: Mon, 12 Oct 2015 14:48:39 +0100 Message-Id: <1444657719-3801-1-git-send-email-will.deacon@arm.com> X-Mailer: git-send-email 2.1.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151012_064906_150577_AE2C2317 X-CRM114-Status: GOOD ( 12.50 ) X-Spam-Score: -6.9 (------) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-6.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [217.140.96.50 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Cc: Mark Rutland , Will Deacon , linux-arm-kernel@lists.infradead.org, arnd@arndb.de, Sudeep Holla MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: will.deacon@arm.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 of_cpu_device_node_get increments the reference count on the CPU device_node, so we must take care to of_node_put once we've finished with it. This patch fixes the perf IRQ probing code to avoid the leak. Cc: Sudeep Holla Cc: Mark Rutland Signed-off-by: Will Deacon --- Arnd/Olof: Please can you take this via arm-soc? It's a non-urgent, yet simple fix and I don't have any other fixes queued for perf. drivers/perf/arm_pmu.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c index 2365a32a595e..be3755c973e9 100644 --- a/drivers/perf/arm_pmu.c +++ b/drivers/perf/arm_pmu.c @@ -823,9 +823,15 @@ static int of_pmu_irq_cfg(struct arm_pmu *pmu) } /* Now look up the logical CPU number */ - for_each_possible_cpu(cpu) - if (dn == of_cpu_device_node_get(cpu)) + for_each_possible_cpu(cpu) { + struct device_node *cpu_dn; + + cpu_dn = of_cpu_device_node_get(cpu); + of_node_put(cpu_dn); + + if (dn == cpu_dn) break; + } if (cpu >= nr_cpu_ids) { pr_warn("Failed to find logical CPU for %s\n",