Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp3200644imb; Tue, 5 Mar 2019 03:34:18 -0800 (PST) X-Google-Smtp-Source: APXvYqyvQ+l3dsviewx2YnhUFGWwxRk0BZgtPM7WrsvQZ/WaF0YkWFAawxTY23XTfUvPJUYeXfCv X-Received: by 2002:a17:902:bb0b:: with SMTP id l11mr710279pls.219.1551785658242; Tue, 05 Mar 2019 03:34:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551785658; cv=none; d=google.com; s=arc-20160816; b=JBaytbqr1TuPhm6EATnTFdHeF/PUy4nUsDUYApSKz2iHHb1Dmj3t02tqdQvQJCgevO 9MzVur6JopgGDfXWhhlDMZfNF2NOwdT5PA+rRtvSB7hbtY2Rbkwbd2eSL7Y3Uv5vSexE DIKW4ft9cs8WU7Mx9vAuE1RMmliKucPUSomltqAB3BHWo6A+QFuJFLB0kew+7O+e2EDB F4mcxTg9nFZXOw8js16XG8GmSmU73iIvhPbFhZYdc7wm1lkEdc8X08MwU09SvXwuiYjW NGqFEggECBcsey41k+H2djzN2APRvW6Ysv9Vh7SKZe/f29siuh7c5qeQ6NyhyrZMKK+l YyGg== 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=wRx5mMpqvdY6UVkp7FP/TPUFZi5LGcryEzeOLWFCuns=; b=QqGopWjBf0I5zu4pI5cfCiHw8s7QIqQt/LczSpKUECX4p6zAcbmXalo+4f/mNwhjEH 5P/qQbBp4MUsB8bS70VSY8gbJzdRbMViSnqV76v+n5p3yD4F4a1WSCzjaFfPbPHe+xaP Uo8wlnWXvx+PAzYMw2sLX0DWzySMC99vIhsS6Y5Nxe6WhKpsVLNv3nNCJp51vnHl0nU2 YqGsSVwU+FwSJpnV5JjlQdhxPnMigotyoc6c0tVA6WH9WnpEWTvGy84lEOhK1aKSLlU+ +DLynIjK1GJ1v5dgLRbgHOMtp3sYLnBpqbIz/aaTP8CZPHICvP/F1P5581VRWA/62eIB cDyA== 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 y8si7463052pgp.115.2019.03.05.03.34.02; Tue, 05 Mar 2019 03:34:18 -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 S1727769AbfCELb6 (ORCPT + 99 others); Tue, 5 Mar 2019 06:31:58 -0500 Received: from out1.zte.com.cn ([202.103.147.172]:40562 "EHLO mxct.zte.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727305AbfCELb5 (ORCPT ); Tue, 5 Mar 2019 06:31:57 -0500 Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id EC47D1D4CC034625443C; Tue, 5 Mar 2019 19:31:55 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id x25BVpff071141; Tue, 5 Mar 2019 19:31:51 +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 2019030519320448-3290744 ; Tue, 5 Mar 2019 19:32:04 +0800 From: Wen Yang To: linux-kernel@vger.kernel.org Cc: wang.yi59@zte.com.cn, Wen Yang , Jason Cooper , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Russell King , linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/4] ARM: mvebu: fix a leaked reference by adding missing of_node_put Date: Tue, 5 Mar 2019 19:32:55 +0800 Message-Id: <1551785577-45896-2-git-send-email-wen.yang99@zte.com.cn> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1551785577-45896-1-git-send-email-wen.yang99@zte.com.cn> References: <1551785577-45896-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-05 19:32:04, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2019-03-05 19:31:47, Serialize complete at 2019-03-05 19:31:47 X-MAIL: mse01.zte.com.cn x25BVpff071141 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-mvebu/pm-board.c:135:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 88, but without a corresponding object release within this functio Signed-off-by: Wen Yang Cc: Jason Cooper Cc: Andrew Lunn Cc: Gregory Clement Cc: Sebastian Hesselbarth Cc: Russell King Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org --- arch/arm/mach-mvebu/pm-board.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-mvebu/pm-board.c b/arch/arm/mach-mvebu/pm-board.c index db17121..1e2c17c 100644 --- a/arch/arm/mach-mvebu/pm-board.c +++ b/arch/arm/mach-mvebu/pm-board.c @@ -79,7 +79,7 @@ static void mvebu_armada_pm_enter(void __iomem *sdram_reg, u32 srcmd) static int __init mvebu_armada_pm_init(void) { struct device_node *np; - struct device_node *gpio_ctrl_np; + struct device_node *gpio_ctrl_np = NULL; int ret = 0, i; if (!of_machine_is_compatible("marvell,axp-gp")) @@ -126,18 +126,23 @@ static int __init mvebu_armada_pm_init(void) goto out; } + if(gpio_ctrl_np) + of_node_put(gpio_ctrl_np); gpio_ctrl_np = args.np; pic_raw_gpios[i] = args.args[0]; } gpio_ctrl = of_iomap(gpio_ctrl_np, 0); - if (!gpio_ctrl) - return -ENOMEM; + if (!gpio_ctrl) { + ret = -ENOMEM; + goto out; + } mvebu_pm_suspend_init(mvebu_armada_pm_enter); out: of_node_put(np); + of_node_put(gpio_ctrl_np); return ret; } -- 2.9.5