Linux Perf Users
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Namhyung Kim" <namhyung@kernel.org>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v1 1/3] perf sched: Add missing perf_session__delete()
Date: Mon, 13 Jul 2026 20:59:07 +0000	[thread overview]
Message-ID: <20260713205907.77D4F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260713204707.2181098-2-namhyung@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The patch introduces a double close of the file descriptor `fd` because `perf_session__delete(session)` inherently closes it before the explicit `close(fd)`.
--

--- Patch [1]: [PATCH v1 1/3] perf sched: Add missing perf_session__delete() ---
commit 2da9bd6a7ce8e17e442d8be81b1b57837aaee6e1
Author: Namhyung Kim <namhyung@kernel.org>

perf sched: Add missing perf_session__delete()

This patch addresses an ASAN-reported memory leak in the perf sched stats
record command by explicitly deleting the session before returning.

> diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
> index 6e0d8f4d270e2..68147a0be5c71 100644
> --- a/tools/perf/builtin-sched.c
> +++ b/tools/perf/builtin-sched.c
> @@ -4027,6 +4027,7 @@ static int perf_sched__schedstat_record(struct perf_sched *sched,
>  	else
>  		fprintf(stderr, "[ perf sched stats: Failed !! ]\n");
>  
> +	perf_session__delete(session);
>  	evlist__put(evlist);
>  	close(fd);

[Severity: Medium]
Does adding perf_session__delete() result in closing the file descriptor twice?

Since perf_session__delete() internally closes the file descriptor associated
with the session data, the subsequent explicit close(fd) will attempt to
close it again. This could return EBADF or erroneously close an unrelated
file descriptor if another thread opens a file in the meantime.

>  	return err;
>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260713204707.2181098-1-namhyung@kernel.org?part=1

  reply	other threads:[~2026-07-13 20:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-13 20:47 [PATCH v1 0/3] perf sched stats: Fix memory leaks Namhyung Kim
2026-07-13 20:47 ` [PATCH v1 1/3] perf sched: Add missing perf_session__delete() Namhyung Kim
2026-07-13 20:59   ` sashiko-bot [this message]
2026-07-13 23:00     ` Namhyung Kim
2026-07-13 20:47 ` [PATCH v1 2/3] perf sched: Fix memory leaks in perf sched stats report Namhyung Kim
2026-07-13 20:47 ` [PATCH v1 3/3] perf sched: Free subcommand string after perf sched stats Namhyung Kim

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=20260713205907.77D4F1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=namhyung@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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