Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp308896imb; Fri, 1 Mar 2019 00:57:59 -0800 (PST) X-Google-Smtp-Source: APXvYqzwAtmo1E4O9v4ilA40naEuKBZZZRPyiD2yG+mAMrok4x9EYjdGX5NtA7Z4AtMieO6Cx55M X-Received: by 2002:a65:63c2:: with SMTP id n2mr3734239pgv.439.1551430679006; Fri, 01 Mar 2019 00:57:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551430678; cv=none; d=google.com; s=arc-20160816; b=mh8iJV3uu193plBKiSpbtdyED2XNO8bOWOqIFjNxsz8mX1uD6HD93MNWuBHnUsywnj HAHgGceOc52OwltJPY99XMSg0Tzg8y0EVE1uL7xmuXCqqe+d+1NDoKy6c30ALf01Yon8 qrgEoByCK0KRACQ03UV1M2IjcK0xlnW55d+o0SLhRxIPb+BdiKVZuvhHnVe+zyZQzpnM yLOuYwqqaJQ6jqEFek1jePTxYc2k1jMTHOqWJM6oDvariGdOZKDwoveo1yZBdDWpVU9N wVgWWQeoltKavgWIt7eVZX5P1qosS+JlZIvjKZZKkdNgxBXL+DPbP3PzEKiBw39IcOP1 LQSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=Oar4AnCB77WxZNpahJqqTa3qGSLTb18dGvC3U+5FNtE=; b=YCEUmxBTEsa3AnvcoK/0mqO5gFrvEcWhgg7AHjHLzgwrOZK/6Oa0pXW7MttjUOeiyI hbzrtJjxPP9vmFkJmc9bkmTg32di1NNaXd3bLKvEyOdUF59aXT4zaHFY/546V1OUMZmT fGUtxGWK2ZGvFd27ybPuLOYvJLTqixYkDzDPA6BjF+oRLj8o9C3/ahzUQk5DCJbkIdtU 7KB++cOM52HWeLp4HftyQDPP17+UYinkd9ORBjJ2xlft/QjETmwM/0WKyokF+3Y5SD4W vgJKbLo4HMtYXYlkJP7MmoR8Coy1lgDhhBWlsp8Q0TcXGlP2T7tw9nmUHwysKEgl5fbO hKYQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 11si19749920pfh.90.2019.03.01.00.57.43; Fri, 01 Mar 2019 00:57:58 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387430AbfCAI5M (ORCPT + 99 others); Fri, 1 Mar 2019 03:57:12 -0500 Received: from mxhk.zte.com.cn ([63.217.80.70]:11802 "EHLO mxhk.zte.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726195AbfCAI5L (ORCPT ); Fri, 1 Mar 2019 03:57:11 -0500 Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id 0BD96B86D0BDC44FF4DF; Fri, 1 Mar 2019 16:57:09 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id x218uwJa086664; Fri, 1 Mar 2019 16:56:58 +0800 (GMT-8) (envelope-from wen.yang99@zte.com.cn) Received: from fox-host8.localdomain ([10.74.120.8]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2019030116573748-2498957 ; Fri, 1 Mar 2019 16:57:37 +0800 From: Wen Yang To: liviu.dudau@arm.com Cc: sudeep.holla@arm.com, lorenzo.pieralisi@arm.com, linux@armlinux.org.uk, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kgene@kernel.org, krzk@kernel.org, linux-samsung-soc@vger.kernel.org, michal.simek@xilinx.com, afaerber@suse.de, manivannan.sadhasivam@linaro.org, dinguyen@kernel.org, heiko@sntech.de, linux-rockchip@lists.infradead.org, f.fainelli@gmail.com, rjui@broadcom.com, sbranden@broadcom.com, bcm-kernel-feedback-list@broadcom.com, linus.walleij@linaro.org, avifishman70@gmail.com, tmaimon77@gmail.com, venture@google.com, yuenn@google.com, brendanhiggins@google.com, openbmc@lists.ozlabs.org, xuwei5@hisilicon.com, maxime.ripard@bootlin.com, wens@csie.org, catalin.marinas@arm.com, will.deacon@arm.com, horms@verge.net.au, magnus.damm@gmail.com, linux-renesas-soc@vger.kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, fabio.estevam@nxp.com, linux-imx@nxp.com, wang.yi59@zte.com.cn, Wen Yang Subject: [PATCH 04/15] ARM: hisi: fix a leaked reference by addingmissing of_node_put Date: Fri, 1 Mar 2019 16:56:45 +0800 Message-Id: <1551430616-42014-4-git-send-email-wen.yang99@zte.com.cn> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1551430616-42014-1-git-send-email-wen.yang99@zte.com.cn> References: <1551430616-42014-1-git-send-email-wen.yang99@zte.com.cn> X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2019-03-01 16:57:37, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2019-03-01 16:56:43, Serialize complete at 2019-03-01 16:56:43 X-MAIL: mse01.zte.com.cn x218uwJa086664 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The call to of_get_next_child returns a node pointer with refcount incremented thus it must be explicitly decremented after the last usage. Detected by coccinelle with the following warnings: ./arch/arm/mach-hisi/platsmp.c:74:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 66, but without a corresponding object release within this function. ./arch/arm/mach-hisi/platsmp.c:78:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 66, but without a corresponding object release within this function. ./arch/arm/mach-hisi/platmcpm.c:337:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 275, but without a corresponding object release within this function. ./arch/arm/mach-hisi/platmcpm.c:347:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 275, but without a corresponding object release within this function. ./arch/arm/mach-hisi/platmcpm.c:337:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 284, but without a corresponding object release within this function. ./arch/arm/mach-hisi/platmcpm.c:347:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 284, but without a corresponding object release within this function. ./arch/arm/mach-hisi/platmcpm.c:337:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 287, but without a corresponding object release within this function. ./arch/arm/mach-hisi/platmcpm.c:347:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 287, but without a corresponding object release within this function. Signed-off-by: Wen Yang Cc: Wei Xu Cc: Russell King Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org --- arch/arm/mach-hisi/platmcpm.c | 12 ++++++++++-- arch/arm/mach-hisi/platsmp.c | 7 +++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/arch/arm/mach-hisi/platmcpm.c b/arch/arm/mach-hisi/platmcpm.c index f66815c..695423c 100644 --- a/arch/arm/mach-hisi/platmcpm.c +++ b/arch/arm/mach-hisi/platmcpm.c @@ -277,6 +277,7 @@ static int __init hip04_smp_init(void) goto err; ret = of_property_read_u32_array(np, "boot-method", &hip04_boot_method[0], 4); + of_node_put(np); if (ret) goto err; @@ -285,12 +286,14 @@ static int __init hip04_smp_init(void) if (!np_sctl) goto err; np_fab = of_find_compatible_node(NULL, NULL, "hisilicon,hip04-fabric"); - if (!np_fab) + if (!np_fab) { + of_node_put(np_sctl); goto err; + } ret = memblock_reserve(hip04_boot_method[0], hip04_boot_method[1]); if (ret) - goto err; + goto err_put_node; relocation = ioremap(hip04_boot_method[2], hip04_boot_method[3]); if (!relocation) { @@ -334,6 +337,8 @@ static int __init hip04_smp_init(void) iounmap(relocation); smp_set_ops(&hip04_smp_ops); + of_node_put(np_fab); + of_node_put(np_sctl); return ret; err_table: iounmap(fabric); @@ -343,6 +348,9 @@ static int __init hip04_smp_init(void) iounmap(relocation); err_reloc: memblock_free(hip04_boot_method[0], hip04_boot_method[1]); +err_put_node: + of_node_put(np_fab); + of_node_put(np_sctl); err: return ret; } diff --git a/arch/arm/mach-hisi/platsmp.c b/arch/arm/mach-hisi/platsmp.c index da5689a..ecc68fa 100644 --- a/arch/arm/mach-hisi/platsmp.c +++ b/arch/arm/mach-hisi/platsmp.c @@ -71,14 +71,17 @@ static void __init hi3xxx_smp_prepare_cpus(unsigned int max_cpus) ctrl_base = of_iomap(np, 0); if (!ctrl_base) { pr_err("failed to map address\n"); - return; + goto out_put_node; } if (of_property_read_u32(np, "smp-offset", &offset) < 0) { pr_err("failed to find smp-offset property\n"); - return; + goto out_put_node; } ctrl_base += offset; } + +out_put_node: + of_node_put(np); } static int hi3xxx_boot_secondary(unsigned int cpu, struct task_struct *idle) -- 2.9.5