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 20030C05027 for ; Thu, 2 Feb 2023 16:57:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232301AbjBBQ46 (ORCPT ); Thu, 2 Feb 2023 11:56:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229608AbjBBQ44 (ORCPT ); Thu, 2 Feb 2023 11:56:56 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCD7065EF4 for ; Thu, 2 Feb 2023 08:56:55 -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 ams.source.kernel.org (Postfix) with ESMTPS id 87A78B8274E for ; Thu, 2 Feb 2023 16:56:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A8C5C433EF; Thu, 2 Feb 2023 16:56:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675357013; bh=HYXDxSkz4syAEX51RYyCe4qxwfwbOeU+++1WVQI/ZZY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=U+wYKAEEN3ytaCAhCX+CNbEKVDk9LwoSsyt6WkldXG3H6pnKAXKfAzySvGUqfCGyj xKY+KmnFJJbwRIKEheZzSTm6ha3iKODutzm8of7fBfpZfm0fC4lqMKCpavdvHjgsbb 711hsPIskrFYUeo9WXwLnxD6gzAnQQU1BceWLtwRc3IneWXGpNJiP99tO8evxR0EKF UWXdY51O/EptYp7Rzr0jhij4L1bmqhAoxyeMQzlvx60xjGgnoHGYGVe45O4UYVdNdK 9YkgB1ayzt56ohcPPlx+2kytbMNHTca2ItKsxH4UyWYLJRFLRTG5VBjKIGP02fu+9S A+ZuWSj4/FyuA== 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 1pNctG-006sNZ-WD; Thu, 02 Feb 2023 16:56:51 +0000 Date: Thu, 02 Feb 2023 16:56:50 +0000 Message-ID: <867cx00zvx.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: References: <20230202151554.2310273-1-gregkh@linuxfoundation.org> <868rhg109t.wl-maz@kernel.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 16:51:50 +0000, Greg Kroah-Hartman wrote: > > On Thu, Feb 02, 2023 at 04:48:30PM +0000, Marc Zyngier wrote: > > 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? > > Sure, I can, but how often are irq domains removed from the system under > a normal operation? As many time as you want if you're doing virtualisation and have the right sort of HW (anything GICv4.x, for example, which will create per-VM irqdomains). > Or you can take it through your tree and add that? I too can take > it through mine, which ever is easier for you. Sure, I can queue that, although that will probably be next week. Thanks, M. -- Without deviation from the norm, progress is not possible.