linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-trace-kernel@vger.kernel.org
Cc: Jens Axboe <axboe@kernel.dk>,
	Steven Rostedt <rostedt@goodmis.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] trace/blktrace: fix memory leak with using debugfs_lookup()
Date: Sat, 4 Feb 2023 15:17:04 -0800	[thread overview]
Message-ID: <3ad1c3b3-f54d-4b0e-2441-ab348d099f3f@acm.org> (raw)
In-Reply-To: <20230202141956.2299521-1-gregkh@linuxfoundation.org>

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>

  reply	other threads:[~2023-02-04 23:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2023-02-06 16:29 ` Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3ad1c3b3-f54d-4b0e-2441-ab348d099f3f@acm.org \
    --to=bvanassche@acm.org \
    --cc=axboe@kernel.dk \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).