]> Git Repo - J-linux.git/commitdiff
kernel/printk/index.c: fix memory leak with using debugfs_lookup()
authorGreg Kroah-Hartman <[email protected]>
Thu, 2 Feb 2023 15:14:11 +0000 (16:14 +0100)
committerPetr Mladek <[email protected]>
Fri, 3 Feb 2023 09:42:02 +0000 (10:42 +0100)
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: Chris Down <[email protected]>
Cc: Petr Mladek <[email protected]>
Cc: Sergey Senozhatsky <[email protected]>
Cc: Steven Rostedt <[email protected]>
Cc: John Ogness <[email protected]>
Cc: [email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
Reviewed-by: Sergey Senozhatsky <[email protected]>
Reviewed-by: John Ogness <[email protected]>
Reviewed-by: Petr Mladek <[email protected]>
Signed-off-by: Petr Mladek <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
kernel/printk/index.c

index c85be186a7832c4431ea2fcffd2800a2b5215e3a..a6b27526baaf6f1eedde94858ec50e52dc2ac060 100644 (file)
@@ -145,7 +145,7 @@ static void pi_create_file(struct module *mod)
 #ifdef CONFIG_MODULES
 static void pi_remove_file(struct module *mod)
 {
-       debugfs_remove(debugfs_lookup(pi_get_module_name(mod), dfs_index));
+       debugfs_lookup_and_remove(pi_get_module_name(mod), dfs_index);
 }
 
 static int pi_module_notify(struct notifier_block *nb, unsigned long op,
This page took 0.050098 seconds and 4 git commands to generate.