kernel/printk/index.c: fix memory leak with using debugfs_lookup()
Subsystems (2)
PATCH 1/1 kernel/printk/index.c: fix memory leak with using debugfs_lookup()
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.
--- kernel/printk/index.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/printk/index.c +1 -1
@@ -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,
Signature · 1 line
2.39.1
Quoted 6 lines · Greg Kroah-Hartman
When calling
debugfs_lookup()the result must havedput()called on it, otherwise the memory will leak over time. To make things simpler, just calldebugfs_lookup_and_remove()instead which handles all of the logic at once.
Quoted 7 lines
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]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Quoted 5 lines · Greg Kroah-Hartman
When calling
debugfs_lookup()the result must havedput()called on it, otherwise the memory will leak over time. To make things simpler, just calldebugfs_lookup_and_remove()instead which handles all of the logic at once.
Quoted 7 lines
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]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Quoted 5 lines · Greg Kroah-Hartman
When calling
debugfs_lookup()the result must havedput()called on it, otherwise the memory will leak over time. To make things simpler, just calldebugfs_lookup_and_remove()instead which handles all of the logic at once.
Quoted 7 lines
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]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Best Regards,
Petr
Petr Mladek
maintainerQuoted 5 lines · Greg Kroah-Hartman
When calling
debugfs_lookup()the result must havedput()called on it, otherwise the memory will leak over time. To make things simpler, just calldebugfs_lookup_and_remove()instead which handles all of the logic at once.
Quoted 7 lines
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]>Signed-off-by Greg Kroah-Hartman <[email protected]>
JFYI, the patch has been committed into printk/linux.git, branch for-6.3.
Best Regards,
Petr
Quoted 14 lines · Petr Mladek
Quoted 5 lines · Greg Kroah-Hartman
When calling
debugfs_lookup()the result must havedput()called on it, otherwise the memory will leak over time. To make things simpler, just calldebugfs_lookup_and_remove()instead which handles all of the logic at once.Quoted 7 lines
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]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Quoted 1 line
JFYI, the patch has been committed into printk/linux.git, branch for-6.3.
Wonderful, thank you!
greg k-h