From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1827AC7618B for ; Fri, 26 Jul 2019 13:22:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E8DD422ADA for ; Fri, 26 Jul 2019 13:22:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727081AbfGZNWc (ORCPT ); Fri, 26 Jul 2019 09:22:32 -0400 Received: from foss.arm.com ([217.140.110.172]:43468 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726001AbfGZNWc (ORCPT ); Fri, 26 Jul 2019 09:22:32 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 82252337; Fri, 26 Jul 2019 06:22:31 -0700 (PDT) Received: from big-swifty.misterjones.org (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A6AD13F694; Fri, 26 Jul 2019 06:22:30 -0700 (PDT) Date: Fri, 26 Jul 2019 14:22:29 +0100 Message-ID: <867e85nd62.wl-marc.zyngier@arm.com> From: Marc Zyngier To: Nishka Dasgupta Cc: tglx@linutronix.de, jason@lakedaemon.net, linux-kernel@vger.kernel.org Subject: Re: [PATCH] irqchip: irq-mbigen: Add of_node_put() before return In-Reply-To: <20190723103910.8006-1-nishkadg.linux@gmail.com> References: <20190723103910.8006-1-nishkadg.linux@gmail.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 EasyPG/1.0.0 Emacs/26 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) Organization: ARM Ltd MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 23 Jul 2019 11:39:10 +0100, Nishka Dasgupta wrote: > > Each iteration of for_each_child_of_node puts the previous node, but > in the case of a return from the middle of the loop, there is no put, > thus causing a memory leak. Add an of_node_put before the return in > three places. > Issue found with Coccinelle. > > Signed-off-by: Nishka Dasgupta > --- > drivers/irqchip/irq-mbigen.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/drivers/irqchip/irq-mbigen.c b/drivers/irqchip/irq-mbigen.c > index 3dd28382d5f5..3f09f658e8e2 100644 > --- a/drivers/irqchip/irq-mbigen.c > +++ b/drivers/irqchip/irq-mbigen.c > @@ -241,12 +241,15 @@ static int mbigen_of_create_domain(struct platform_device *pdev, > > parent = platform_bus_type.dev_root; > child = of_platform_device_create(np, NULL, parent); > - if (!child) > + if (!child) { > + of_node_put(np); > return -ENOMEM; > + } > > if (of_property_read_u32(child->dev.of_node, "num-pins", > &num_pins) < 0) { > dev_err(&pdev->dev, "No num-pins property\n"); > + of_node_put(np); > return -EINVAL; > } > > @@ -254,8 +257,10 @@ static int mbigen_of_create_domain(struct platform_device *pdev, > mbigen_write_msg, > &mbigen_domain_ops, > mgn_chip); > - if (!domain) > + if (!domain) { > + of_node_put(np); > return -ENOMEM; > + } > } > > return 0; > -- > 2.19.1 > Applied, thanks. M. -- Jazz is not dead, it just smells funny.