Re: [PATCH 2/2] sched/debug: fix dentry leak in update_sched_domain_debugfs

From: Greg Kroah-Hartman
Date: Fri Sep 02 2022 - 09:52:55 EST


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.
>
> Cc: Major Chen <major.chen@xxxxxxxxxxx>
> Cc: stable <stable@xxxxxxxxxx>
> Reported-by: Kuyo Chang <kuyo.chang@xxxxxxxxxxxx>
> Tested-by: Kuyo Chang <kuyo.chang@xxxxxxxxxxxx>
> Cc: Ingo Molnar <mingo@xxxxxxxxxx>
> Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> Cc: Juri Lelli <juri.lelli@xxxxxxxxxx>
> Cc: Vincent Guittot <vincent.guittot@xxxxxxxxxx>
> Cc: Dietmar Eggemann <dietmar.eggemann@xxxxxxx>
> Cc: Steven Rostedt <rostedt@xxxxxxxxxxx>
> Cc: Ben Segall <bsegall@xxxxxxxxxx>
> Cc: Mel Gorman <mgorman@xxxxxxx>
> Cc: Daniel Bristot de Oliveira <bristot@xxxxxxxxxx>
> Cc: Valentin Schneider <vschneid@xxxxxxxxxx>
> Cc: Matthias Brugger <matthias.bgg@xxxxxxxxx>
> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> ---
> kernel/sched/debug.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)

As this needs patch 1/2 to work properly, and Kuyo has tested this out
already, I'll take both of them through my driver core git tree to Linus
so that we can start getting the other debugfs_lookup() leaks fixed up
as well.

thanks,

greg k-h