Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1592424yba; Sun, 21 Apr 2019 10:25:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqz8ngl86UrVY8XIQz2f6QUBedvkuw5R1DNz3jPrrpioAWnUOfj60kH5SF+KGLO2sSUFjf66 X-Received: by 2002:a62:62c2:: with SMTP id w185mr15907764pfb.237.1555867544176; Sun, 21 Apr 2019 10:25:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555867544; cv=none; d=google.com; s=arc-20160816; b=m3sWhhebONMGoaNAyI844pJDuHF9vWL1jqQxvuY8rL20qUHz8bZdHPRkHE9hBYDS3j zcNFDe7+z1kueS1xsLvVyNxedzsgIqccB2dyHsnP+w923giIyoF9Ha6R5rKAa/u2XzUs r6F/7dL7aSEgwcAvyWqGt1rJUEEzIvA5dCpaaURWEldwQoiw2qFuTzWKte1OnL6J8ngA X7AeSC6WdT2dsWniLasuK1V2qWC5iZ2QCaC+mN0rigJAeZh3RRVJryJdsFnAgOQqdB3I 03ktxTYW9VND2NDfnfyb0eOpKzgqX6JTJcqoEdWqUBrqJoDROogBSorD96bvUeQOOjeG C3Wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=622x0ujJD6UgpUpQZkKSOQMMptMrY2+tSOP46/7xxxE=; b=UYFAWG1rUwUh9kDfUa6sZYd2UJspH9wBsLSeH9A+mSJKasHIEdHbp03V7B5zMC5st/ ymmSkHvkmUyVe+YHYGwMyav+AEpmhrBr5jUkC/nu+B6lY1ZoyB50MXnIMb4BkJEJPkmd jYgrelj5KCFh1nzbyfKr4YulPslcswPreiY6YP5D0/fTBnST21nJTCaTdge5RQyDZ7S2 +PIQPDnTJ7QhHj2GFqcNoKwOT9E2ajdRkWcJt3Gb+HfuVs4v3/ipPDeyfrAGtQHJnoon pjit5OLeOJC/fU2fyRmQS9FyX9fNeTp+T//DHY44+zuxBcfpyjgsQ40+56TiAKzkB853 NGaA== 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 b18si10175086pgj.500.2019.04.21.10.25.29; Sun, 21 Apr 2019 10:25:44 -0700 (PDT) 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 S1727865AbfDURYW (ORCPT + 99 others); Sun, 21 Apr 2019 13:24:22 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:60527 "EHLO relay1-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726645AbfDURYV (ORCPT ); Sun, 21 Apr 2019 13:24:21 -0400 X-Originating-IP: 93.23.249.69 Received: from localhost (69.249.23.93.rev.sfr.net [93.23.249.69]) (Authenticated sender: gregory.clement@bootlin.com) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id A7977240002; Sun, 21 Apr 2019 17:24:18 +0000 (UTC) From: Gregory CLEMENT To: Wen Yang , linux-kernel@vger.kernel.org Cc: wang.yi59@zte.com.cn, Wen Yang , Jason Cooper , Andrew Lunn , Sebastian Hesselbarth , Russell King , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH 2/4] ARM: mvebu: fix a leaked reference by adding missing of_node_put In-Reply-To: <1551785577-45896-2-git-send-email-wen.yang99@zte.com.cn> References: <1551785577-45896-1-git-send-email-wen.yang99@zte.com.cn> <1551785577-45896-2-git-send-email-wen.yang99@zte.com.cn> Date: Sun, 21 Apr 2019 19:24:17 +0200 Message-ID: <877ebn8e66.fsf@FE-laptop> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Wen Yang, > 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 Applied on mvebu/arm Thanks, Gregory > --- > 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 > -- Gregory Clement, Bootlin Embedded Linux and Kernel engineering http://bootlin.com