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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7FDCEC05027 for ; Thu, 2 Feb 2023 16:48:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232125AbjBBQsu (ORCPT ); Thu, 2 Feb 2023 11:48:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232292AbjBBQsf (ORCPT ); Thu, 2 Feb 2023 11:48:35 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BCF66DFFD for ; Thu, 2 Feb 2023 08:48:34 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1FE1F61C0A for ; Thu, 2 Feb 2023 16:48:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8443CC433EF; Thu, 2 Feb 2023 16:48:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675356513; bh=yqau+lyHPnKSiAXYYDlbNfpXiUc4jkHXtYmVXoZQviU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=NSqcqBaZr+FRUnrFa7uqTlje068HZbBWvJysL3GWozA7JOFgHbizvhKxNzPnENeIM ojxz9Eeo9nG5S6s9AFSLn6czW1Ih7lr+G2HNxAAzthJmJztjuHUQ7sqjbZk/JogWJt DslLoaNrGZIfF5jRbY+rPgnGtw9xoptQ7DIcomQyljnldRwrUxWD7GnzdvhO4EebhE jm6C7u388uUAvB9gMyxEDlrelBuoiGSpJ//OZZ1WPKsEIXqtHu8eBcW7T/+9RvGwY0 wlXVcV2LOSszSqI2W2G/M9z/ougunte45PCHmrKepQZNYZX66/MaN6fpWqHCKUeQRO N3pKoAERNCORw== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pNclD-006sHq-AD; Thu, 02 Feb 2023 16:48:31 +0000 Date: Thu, 02 Feb 2023 16:48:30 +0000 Message-ID: <868rhg109t.wl-maz@kernel.org> From: Marc Zyngier To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, Thomas Gleixner Subject: Re: [PATCH] kernel/irq/irqdomain.c: fix memory leak with using debugfs_lookup() In-Reply-To: <20230202151554.2310273-1-gregkh@linuxfoundation.org> References: <20230202151554.2310273-1-gregkh@linuxfoundation.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/28.2 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, tglx@linutronix.de X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 02 Feb 2023 15:15:54 +0000, Greg Kroah-Hartman wrote: > > When calling debugfs_lookup() the result must have dput() called on it, > otherwise the memory will leak over time. To make things simpler, just > call debugfs_lookup_and_remove() instead which handles all of the logic > at once. > > Cc: Marc Zyngier > Cc: Thomas Gleixner > Cc: linux-kernel@vger.kernel.org > Signed-off-by: Greg Kroah-Hartman > --- > kernel/irq/irqdomain.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c > index 8fe1da9614ee..e2096b51c004 100644 > --- a/kernel/irq/irqdomain.c > +++ b/kernel/irq/irqdomain.c > @@ -1915,7 +1915,7 @@ static void debugfs_add_domain_dir(struct irq_domain *d) > > static void debugfs_remove_domain_dir(struct irq_domain *d) > { > - debugfs_remove(debugfs_lookup(d->name, domain_dir)); > + debugfs_lookup_and_remove(d->name, domain_dir); > } > > void __init irq_domain_debugfs_init(struct dentry *root) Reviewed-by: Marc Zyngier Maybe add a Cc stable to get this in 6.1? Thanks, M. -- Without deviation from the norm, progress is not possible.