* [PATCH] trace/blktrace: fix memory leak with using debugfs_lookup()
@ 2023-02-02 14:19 Greg Kroah-Hartman
2023-02-04 23:17 ` Bart Van Assche
2023-02-06 16:29 ` Jens Axboe
0 siblings, 2 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2023-02-02 14:19 UTC (permalink / raw)
To: linux-trace-kernel
Cc: Greg Kroah-Hartman, Jens Axboe, Steven Rostedt, Masami Hiramatsu,
linux-block, linux-kernel
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: Jens Axboe <axboe@kernel.dk>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: linux-block@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-trace-kernel@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
kernel/trace/blktrace.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index 918a7d12df8f..5743be559415 100644
--- a/kernel/trace/blktrace.c
+++ b/kernel/trace/blktrace.c
@@ -320,8 +320,8 @@ static void blk_trace_free(struct request_queue *q, struct blk_trace *bt)
* under 'q->debugfs_dir', thus lookup and remove them.
*/
if (!bt->dir) {
- debugfs_remove(debugfs_lookup("dropped", q->debugfs_dir));
- debugfs_remove(debugfs_lookup("msg", q->debugfs_dir));
+ debugfs_lookup_and_remove("dropped", q->debugfs_dir);
+ debugfs_lookup_and_remove("msg", q->debugfs_dir);
} else {
debugfs_remove(bt->dir);
}
--
2.39.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] trace/blktrace: fix memory leak with using debugfs_lookup()
2023-02-02 14:19 [PATCH] trace/blktrace: fix memory leak with using debugfs_lookup() Greg Kroah-Hartman
@ 2023-02-04 23:17 ` Bart Van Assche
2023-02-06 16:29 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Bart Van Assche @ 2023-02-04 23:17 UTC (permalink / raw)
To: Greg Kroah-Hartman, linux-trace-kernel
Cc: Jens Axboe, Steven Rostedt, Masami Hiramatsu, linux-block,
linux-kernel
On 2/2/23 06:19, 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: Jens Axboe <axboe@kernel.dk>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Masami Hiramatsu <mhiramat@kernel.org>
> Cc: linux-block@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-trace-kernel@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
> kernel/trace/blktrace.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
> index 918a7d12df8f..5743be559415 100644
> --- a/kernel/trace/blktrace.c
> +++ b/kernel/trace/blktrace.c
> @@ -320,8 +320,8 @@ static void blk_trace_free(struct request_queue *q, struct blk_trace *bt)
> * under 'q->debugfs_dir', thus lookup and remove them.
> */
> if (!bt->dir) {
> - debugfs_remove(debugfs_lookup("dropped", q->debugfs_dir));
> - debugfs_remove(debugfs_lookup("msg", q->debugfs_dir));
> + debugfs_lookup_and_remove("dropped", q->debugfs_dir);
> + debugfs_lookup_and_remove("msg", q->debugfs_dir);
> } else {
> debugfs_remove(bt->dir);
> }
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] trace/blktrace: fix memory leak with using debugfs_lookup()
2023-02-02 14:19 [PATCH] trace/blktrace: fix memory leak with using debugfs_lookup() Greg Kroah-Hartman
2023-02-04 23:17 ` Bart Van Assche
@ 2023-02-06 16:29 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2023-02-06 16:29 UTC (permalink / raw)
To: linux-trace-kernel, Greg Kroah-Hartman
Cc: Steven Rostedt, Masami Hiramatsu, linux-block, linux-kernel
On Thu, 02 Feb 2023 15:19:56 +0100, 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.
>
>
Applied, thanks!
[1/1] trace/blktrace: fix memory leak with using debugfs_lookup()
commit: 83e8864fee26f63a7435e941b7c36a20fd6fe93e
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-02-06 16:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-02 14:19 [PATCH] trace/blktrace: fix memory leak with using debugfs_lookup() Greg Kroah-Hartman
2023-02-04 23:17 ` Bart Van Assche
2023-02-06 16:29 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).