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 1E417C38145 for ; Fri, 2 Sep 2022 14:29:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236401AbiIBO3S (ORCPT ); Fri, 2 Sep 2022 10:29:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236739AbiIBO13 (ORCPT ); Fri, 2 Sep 2022 10:27:29 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8D73168A04 for ; Fri, 2 Sep 2022 06:54:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=P7wIoFqf5p36KrKtv5UDBZ0MqutgeRhjhLt/RxYLrNI=; b=n8jSwtqq6VZlmvdbjh8wmD7wHt 992tnKu9B5qEAn+04B3IBRdVRXfhSKSGbdUbK6FOsphGe81exNCfcpdGFhfd2QcBAsUlESYyOkvam gROGc/twSDTKU2OoUS2pSg34TqnC7+87aaMgO2dLYzftp6lV5jbGWzPvDPnJE+zwBh0m7O645lROV NximJkP32vjiSYYEmto0mRv40ulkg55JaZiuV2l7w4EM+1PWS5A/Vk00uXkp0GljwePvJ299vFAnU rrN5PQzm0v2mKV+5mXHmIOAGFlwJBMqKrIrqjg/Q44QVXvH+ZpjV+cgt58Va9AlBHyk7Kd+AR8yfb xEe561QQ==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1oU6Gu-008fTr-Ik; Fri, 02 Sep 2022 12:59:44 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id DE79D300431; Fri, 2 Sep 2022 14:59:42 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id A49622B8AE594; Fri, 2 Sep 2022 14:59:42 +0200 (CEST) Date: Fri, 2 Sep 2022 14:59:42 +0200 From: Peter Zijlstra To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, Major Chen , stable , Kuyo Chang , Ingo Molnar , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , Matthias Brugger Subject: Re: [PATCH 2/2] sched/debug: fix dentry leak in update_sched_domain_debugfs Message-ID: References: <20220902123107.109274-1-gregkh@linuxfoundation.org> <20220902123107.109274-2-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220902123107.109274-2-gregkh@linuxfoundation.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 02, 2022 at 02:31:07PM +0200, Greg Kroah-Hartman wrote: > Kuyo reports that the pattern of using debugfs_remove(debugfs_lookup()) > leaks a dentry and with a hotplug stress test, the machine eventually > runs out of memory. > > Fix this up by using the newly created debugfs_lookup_and_remove() call > instead which properly handles the dentry reference counting logic. > Signed-off-by: Greg Kroah-Hartman Acked-by: Peter Zijlstra (Intel) > --- > kernel/sched/debug.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c > index bb3d63bdf4ae..667876da8382 100644 > --- a/kernel/sched/debug.c > +++ b/kernel/sched/debug.c > @@ -416,7 +416,7 @@ void update_sched_domain_debugfs(void) > char buf[32]; > > snprintf(buf, sizeof(buf), "cpu%d", cpu); > - debugfs_remove(debugfs_lookup(buf, sd_dentry)); > + debugfs_lookup_and_remove(buf, sd_dentry); > d_cpu = debugfs_create_dir(buf, sd_dentry); > > i = 0; > -- > 2.37.3 >