From patchwork Fri Mar 17 15:02:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 9630943 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 890FF602D6 for ; Fri, 17 Mar 2017 15:17:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D129286B0 for ; Fri, 17 Mar 2017 15:17:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7E4D7286B4; Fri, 17 Mar 2017 15:17:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 03375286B0 for ; Fri, 17 Mar 2017 15:17:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=XCPAnvPU6JatX9N08OURV84NuHzCBz/U6Oq3d3jVtEM=; b=gbiNSfvhhFiZW2YFct7YN4wmuM MuIEsrCvTEXxmyahCNPbCo7V6RIT/MSw8zUSRTx9A8BJUQr0CvI1DTVfZa8N2Zar7MqaeWGWsBvcw 0Kb8R3HFGl9AT+aXkxZ8IxvjoyQ88/RSbuyda2P4ro8X7MkFkDJyLhB7zFpc8agni3N2GfjF6zvMy ASn6OtBwf49ecnenGI4xfUhuyC4WV/XDRoDimsSIg/19q4+gVb5r9jYimKN+P7TdPc7U5OhheQsFd zv0InoHIYmRYffkpDl6a9qSXBqyaVHzp5sxSQC78rmFJhlAWATJve2k8wsZg5G275WjystF7gQGR/ Zwb+NTBA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cotcm-0006ID-LZ; Fri, 17 Mar 2017 15:17:04 +0000 Received: from mail-pg0-x235.google.com ([2607:f8b0:400e:c05::235]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cotQS-0005Zd-Ed for linux-arm-kernel@lists.infradead.org; Fri, 17 Mar 2017 15:04:23 +0000 Received: by mail-pg0-x235.google.com with SMTP id n190so43062935pga.0 for ; Fri, 17 Mar 2017 08:03:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=L+0TWqNd/lwJxEk+l6nkmFJFJZ+3J5TKXp7w41BiOVg=; b=RTuPa3264K/31JEfYr/aGClXC461MBHAAfdHA+r9EIuLSIfAexjcMxdzAbbD8NxHgC se29GJ4CvkSnu4T6IeWDFLhcazlgIkPiAgLmByHb4lulan5+ISRdQm7lbk6T9syRJaEV 2rTSMyTbcYqW2L9+idWtbwMy01OSzB6wwhn2g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=L+0TWqNd/lwJxEk+l6nkmFJFJZ+3J5TKXp7w41BiOVg=; b=Tz/TBXO/+UesPne2PHlfQ0MXTMUh6/a8JUA0nPCWMWQ2qMpsLPgzvERvBOiCMxX8HO Z3FIMYaQRheI+xhs+cBTOQKRilrYl7xfvVXhzpNN6yfnY/MR71fDTkQ6d25nqIS0ctcN qZ9TjTGLXLSDLMSSC/Y76Hdw/+HKpXfh+Wx22MChnCzqGw05cSW5NHWCCNjWjz7xSoDb CTHBOmYJsgDUyx9Sd/NKI+/DCb680ArlYTI7Q+Zpr4Umlgtt75poBsR1jsdlXK7c1QPE ustqiLpRR2C/gvB3N/e8G4e1lLQY2p0onBENGhi+NcTpXJzqiCrqqvEnofVN39uko1OD cUGQ== X-Gm-Message-State: AFeK/H0NHDlpFDkbObHrrjVb/aCLjRh6oAuFK6IXTSa+4tLenGj0OMi8k0KtH4HH3mDg4o3u X-Received: by 10.99.98.2 with SMTP id w2mr16381218pgb.103.1489763039421; Fri, 17 Mar 2017 08:03:59 -0700 (PDT) Received: from localhost.localdomain ([103.230.219.215]) by smtp.gmail.com with ESMTPSA id f125sm17482582pfc.4.2017.03.17.08.03.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 17 Mar 2017 08:03:58 -0700 (PDT) From: Leo Yan To: Rob Herring , Mark Rutland , Wei Xu , Catalin Marinas , Will Deacon , Andy Gross , David Brown , Michael Turquette , Stephen Boyd , Mathieu Poirier , Leo Yan , Guodong Xu , John Stultz , Greg Kroah-Hartman , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-clk@vger.kernel.org, mike.leach@linaro.org, Suzuki.Poulose@arm.com, sudeep.holla@arm.com Subject: [PATCH v4 2/7] coresight: of_get_coresight_platform_data: Add missing of_node_put Date: Fri, 17 Mar 2017 23:02:18 +0800 Message-Id: <1489762943-25849-3-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1489762943-25849-1-git-send-email-leo.yan@linaro.org> References: <1489762943-25849-1-git-send-email-leo.yan@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170317_080420_779490_E2FC13CB X-CRM114-Status: GOOD ( 14.36 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Suzuki K Poulose MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Suzuki K Poulose The of_get_coresight_platform_data iterates over the possible CPU nodes to find a given cpu phandle. However it does not drop the reference to the node pointer returned by the of_get_coresight_platform_data. [Leo: minor tweaks for of_get_coresight_platform_data] Cc: Leo Yan Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/of_coresight.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/hwtracing/coresight/of_coresight.c b/drivers/hwtracing/coresight/of_coresight.c index 629e031..917ca39 100644 --- a/drivers/hwtracing/coresight/of_coresight.c +++ b/drivers/hwtracing/coresight/of_coresight.c @@ -108,7 +108,8 @@ struct coresight_platform_data *of_get_coresight_platform_data( struct coresight_platform_data *pdata; struct of_endpoint endpoint, rendpoint; struct device *rdev; - struct device_node *dn; + bool found; + struct device_node *dn, *np; struct device_node *ep = NULL; struct device_node *rparent = NULL; struct device_node *rport = NULL; @@ -175,17 +176,19 @@ struct coresight_platform_data *of_get_coresight_platform_data( } while (ep); } - /* Affinity defaults to CPU0 */ - pdata->cpu = 0; dn = of_parse_phandle(node, "cpu", 0); - for (cpu = 0; dn && cpu < nr_cpu_ids; cpu++) { - if (dn == of_get_cpu_node(cpu, NULL)) { - pdata->cpu = cpu; + for_each_possible_cpu(cpu) { + np = of_get_cpu_node(cpu, NULL); + found = (dn == np); + of_node_put(np); + if (found) break; - } } of_node_put(dn); + /* Affinity to CPU0 if no cpu nodes are found */ + pdata->cpu = found ? cpu : 0; + return pdata; } EXPORT_SYMBOL_GPL(of_get_coresight_platform_data);