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: 9630879 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 B5E5B60245 for ; Fri, 17 Mar 2017 15:04:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ACDBC286AD for ; Fri, 17 Mar 2017 15:04:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A1A2D286B2; Fri, 17 Mar 2017 15:04:25 +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=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A0BE286AD for ; Fri, 17 Mar 2017 15:04:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751160AbdCQPEY (ORCPT ); Fri, 17 Mar 2017 11:04:24 -0400 Received: from mail-pg0-f48.google.com ([74.125.83.48]:33985 "EHLO mail-pg0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751088AbdCQPEX (ORCPT ); Fri, 17 Mar 2017 11:04:23 -0400 Received: by mail-pg0-f48.google.com with SMTP id 21so9754069pgg.1 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=pD6Gthp1DErcqO+K4lJwKctcIXgAlgNkHHajBsl4eOJPi4/x9fRdR7heG+u4gb736S xvSLBYVD+BcDWEz8IgVmQc7TG66YJdYtFTdRKazBbUGHpjQYylJw6m74FVxlP+itkLT5 7iTHjiPMctQFpSxKnD215K1TNd2+P50pNG+UpW1p8QFaZw5D+776q6OTzOtr2Pzj13ll BCl0ZFYje1Vye64gEsfgtKFQk+dHNbRb5nieWt7TQhPGzvpLfYPC3UJO4p/vvqwqT+nj G08EyPibw8wt/ae7iE0PRvhuiBwtdWxxUgMI//YDxEoIVlgM9Cyf+2c6mkp5ZofNJlXf KTvw== X-Gm-Message-State: AFeK/H0wpsa3oYR0aVKIqOFJ/77/31W8Et1G6MYRrDAmjxcUS4tzIABh9Iqao3nQ/bMHcUwA 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 Cc: Suzuki K Poulose 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> Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.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 Signed-off-by: Suzuki K Poulose Signed-off-by: Leo Yan --- 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);