* [PATCH] kernel/printk/index.c: fix memory leak with using debugfs_lookup()
@ 2023-02-02 15:14 Greg Kroah-Hartman
2023-02-03 2:53 ` Sergey Senozhatsky
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Greg Kroah-Hartman @ 2023-02-02 15:14 UTC (permalink / raw)
To: linux-kernel
Cc: Greg Kroah-Hartman, Chris Down, Petr Mladek, Sergey Senozhatsky,
Steven Rostedt, John Ogness
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 <chris@chrisdown.name>
Cc: Petr Mladek <pmladek@suse.com>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: John Ogness <john.ogness@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
kernel/printk/index.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/printk/index.c b/kernel/printk/index.c
index c85be186a783..a6b27526baaf 100644
--- a/kernel/printk/index.c
+++ b/kernel/printk/index.c
@@ -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,
--
2.39.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] kernel/printk/index.c: fix memory leak with using debugfs_lookup()
2023-02-02 15:14 [PATCH] kernel/printk/index.c: fix memory leak with using debugfs_lookup() Greg Kroah-Hartman
@ 2023-02-03 2:53 ` Sergey Senozhatsky
2023-02-03 9:11 ` John Ogness
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Sergey Senozhatsky @ 2023-02-03 2:53 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: linux-kernel, Chris Down, Petr Mladek, Sergey Senozhatsky,
Steven Rostedt, John Ogness
On (23/02/02 16:14), Greg Kroah-Hartman wrote:
>
> 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 <chris@chrisdown.name>
> Cc: Petr Mladek <pmladek@suse.com>
> Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: John Ogness <john.ogness@linutronix.de>
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] kernel/printk/index.c: fix memory leak with using debugfs_lookup()
2023-02-02 15:14 [PATCH] kernel/printk/index.c: fix memory leak with using debugfs_lookup() Greg Kroah-Hartman
2023-02-03 2:53 ` Sergey Senozhatsky
@ 2023-02-03 9:11 ` John Ogness
2023-02-03 9:40 ` Petr Mladek
2023-02-03 10:16 ` Petr Mladek
3 siblings, 0 replies; 6+ messages in thread
From: John Ogness @ 2023-02-03 9:11 UTC (permalink / raw)
To: Greg Kroah-Hartman, linux-kernel
Cc: Greg Kroah-Hartman, Chris Down, Petr Mladek, Sergey Senozhatsky,
Steven Rostedt
On 2023-02-02, Greg Kroah-Hartman <gregkh@linuxfoundation.org> wrote:
> 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 <chris@chrisdown.name>
> Cc: Petr Mladek <pmladek@suse.com>
> Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: John Ogness <john.ogness@linutronix.de>
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: John Ogness <john.ogness@linutronix.de>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] kernel/printk/index.c: fix memory leak with using debugfs_lookup()
2023-02-02 15:14 [PATCH] kernel/printk/index.c: fix memory leak with using debugfs_lookup() Greg Kroah-Hartman
2023-02-03 2:53 ` Sergey Senozhatsky
2023-02-03 9:11 ` John Ogness
@ 2023-02-03 9:40 ` Petr Mladek
2023-02-03 10:16 ` Petr Mladek
3 siblings, 0 replies; 6+ messages in thread
From: Petr Mladek @ 2023-02-03 9:40 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: linux-kernel, Chris Down, Sergey Senozhatsky, Steven Rostedt,
John Ogness
On Thu 2023-02-02 16:14:11, Greg Kroah-Hartman wrote:
> 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 <chris@chrisdown.name>
> Cc: Petr Mladek <pmladek@suse.com>
> Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: John Ogness <john.ogness@linutronix.de>
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Best Regards,
Petr
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] kernel/printk/index.c: fix memory leak with using debugfs_lookup()
2023-02-02 15:14 [PATCH] kernel/printk/index.c: fix memory leak with using debugfs_lookup() Greg Kroah-Hartman
` (2 preceding siblings ...)
2023-02-03 9:40 ` Petr Mladek
@ 2023-02-03 10:16 ` Petr Mladek
2023-02-08 12:21 ` Greg Kroah-Hartman
3 siblings, 1 reply; 6+ messages in thread
From: Petr Mladek @ 2023-02-03 10:16 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: linux-kernel, Chris Down, Sergey Senozhatsky, Steven Rostedt,
John Ogness
On Thu 2023-02-02 16:14:11, Greg Kroah-Hartman wrote:
> 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 <chris@chrisdown.name>
> Cc: Petr Mladek <pmladek@suse.com>
> Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: John Ogness <john.ogness@linutronix.de>
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
JFYI, the patch has been committed into printk/linux.git, branch for-6.3.
Best Regards,
Petr
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] kernel/printk/index.c: fix memory leak with using debugfs_lookup()
2023-02-03 10:16 ` Petr Mladek
@ 2023-02-08 12:21 ` Greg Kroah-Hartman
0 siblings, 0 replies; 6+ messages in thread
From: Greg Kroah-Hartman @ 2023-02-08 12:21 UTC (permalink / raw)
To: Petr Mladek
Cc: linux-kernel, Chris Down, Sergey Senozhatsky, Steven Rostedt,
John Ogness
On Fri, Feb 03, 2023 at 11:16:17AM +0100, Petr Mladek wrote:
> On Thu 2023-02-02 16:14:11, Greg Kroah-Hartman wrote:
> > 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 <chris@chrisdown.name>
> > Cc: Petr Mladek <pmladek@suse.com>
> > Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
> > Cc: Steven Rostedt <rostedt@goodmis.org>
> > Cc: John Ogness <john.ogness@linutronix.de>
> > Cc: linux-kernel@vger.kernel.org
> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>
> JFYI, the patch has been committed into printk/linux.git, branch for-6.3.
Wonderful, thank you!
greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-02-08 12:21 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-02 15:14 [PATCH] kernel/printk/index.c: fix memory leak with using debugfs_lookup() Greg Kroah-Hartman
2023-02-03 2:53 ` Sergey Senozhatsky
2023-02-03 9:11 ` John Ogness
2023-02-03 9:40 ` Petr Mladek
2023-02-03 10:16 ` Petr Mladek
2023-02-08 12:21 ` Greg Kroah-Hartman
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.