Takashi Iwai e9bc96
From 8deb87b1e810dd558371e88ffd44339fbef27870 Mon Sep 17 00:00:00 2001
Takashi Iwai e9bc96
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Takashi Iwai e9bc96
Date: Thu, 2 Feb 2023 15:16:20 +0100
Takashi Iwai e9bc96
Subject: [PATCH] drivers: base: component: fix memory leak with using debugfs_lookup()
Takashi Iwai e9bc96
Git-commit: 8deb87b1e810dd558371e88ffd44339fbef27870
Takashi Iwai e9bc96
Patch-mainline: v6.3-rc1
Takashi Iwai e9bc96
References: git-fixes
Takashi Iwai e9bc96
Takashi Iwai e9bc96
When calling debugfs_lookup() the result must have dput() called on it,
Takashi Iwai e9bc96
otherwise the memory will leak over time.  To make things simpler, just
Takashi Iwai e9bc96
call debugfs_lookup_and_remove() instead which handles all of the logic
Takashi Iwai e9bc96
at once.
Takashi Iwai e9bc96
Takashi Iwai e9bc96
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Takashi Iwai e9bc96
Link: https://lore.kernel.org/r/20230202141621.2296458-1-gregkh@linuxfoundation.org
Takashi Iwai e9bc96
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Takashi Iwai e9bc96
Acked-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai e9bc96
Takashi Iwai e9bc96
---
Takashi Iwai e9bc96
 drivers/base/component.c |    2 +-
Takashi Iwai e9bc96
 1 file changed, 1 insertion(+), 1 deletion(-)
Takashi Iwai e9bc96
Takashi Iwai e9bc96
--- a/drivers/base/component.c
Takashi Iwai e9bc96
+++ b/drivers/base/component.c
Takashi Iwai e9bc96
@@ -130,7 +130,7 @@ static void component_master_debugfs_add
Takashi Iwai e9bc96
 
Takashi Iwai e9bc96
 static void component_master_debugfs_del(struct master *m)
Takashi Iwai e9bc96
 {
Takashi Iwai e9bc96
-	debugfs_remove(debugfs_lookup(dev_name(m->parent), component_debugfs_dir));
Takashi Iwai e9bc96
+	debugfs_lookup_and_remove(dev_name(m->parent), component_debugfs_dir);
Takashi Iwai e9bc96
 }
Takashi Iwai e9bc96
 
Takashi Iwai e9bc96
 #else