From: sashiko-bot@kernel.org
To: "Michalis Niarchos" <michael.niarchos@gmail.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH 1/4] perf tools: Fix memory leak in cmd_kvm()
Date: Mon, 03 Aug 2026 10:42:06 +0000 [thread overview]
Message-ID: <20260803104207.90A0E1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260803-perf-kvm-fixes-v1-1-a5db849ac973@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The error check evaluating `if (!file_name)` immediately following `get_filename_for_perf_kvm()` is functionally dead code and prints an obsolete error message.
--
--- Patch [1]: [PATCH 1/4] perf tools: Fix memory leak in cmd_kvm() ---
commit 85aa78ecdd5ada6c616d04d112b0f46542981162
Author: Michalis Niarchos <michael.niarchos@gmail.com>
perf tools: Fix memory leak in cmd_kvm()
filename may get allocated by get_filename_for_perf_kvm(), but is
never freed. Use string literals to remove the need for freeing.
> diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
> index 394302ebdb161..44c6998f2ee5d 100644
> --- a/tools/perf/builtin-kvm.c
> +++ b/tools/perf/builtin-kvm.c
> @@ -606,11 +606,11 @@ static const char *get_filename_for_perf_kvm(void)
> const char *filename;
>
> if (perf_host && !perf_guest)
> - filename = strdup("perf.data.host");
> + filename = "perf.data.host";
> else if (!perf_host && perf_guest)
> - filename = strdup("perf.data.guest");
> + filename = "perf.data.guest";
> else
> - filename = strdup("perf.data.kvm");
> + filename = "perf.data.kvm";
>
> return filename;
> }
[Severity: Low]
Since get_filename_for_perf_kvm() now exclusively returns static string
literals, it can never return NULL.
Is it worth cleaning up the now-dead error handling block in cmd_kvm() that
still checks for allocation failures?
tools/perf/builtin-kvm.c:cmd_kvm() {
...
if (!file_name) {
file_name = get_filename_for_perf_kvm();
if (!file_name) {
pr_err("Failed to allocate memory for filename\n");
return -ENOMEM;
}
}
...
}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260803-perf-kvm-fixes-v1-0-a5db849ac973@gmail.com?part=1
next prev parent reply other threads:[~2026-08-03 10:42 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-03 10:33 [PATCH 0/4] perf tools: Fix memory issues Michalis Niarchos via B4 Relay
2026-08-03 10:33 ` Michalis Niarchos
2026-08-03 10:33 ` [PATCH 1/4] perf tools: Fix memory leak in cmd_kvm() Michalis Niarchos via B4 Relay
2026-08-03 10:33 ` Michalis Niarchos
2026-08-03 10:42 ` sashiko-bot [this message]
2026-08-03 10:33 ` [PATCH 2/4] perf tools: Fix memory leak in kvm_events_report() Michalis Niarchos via B4 Relay
2026-08-03 10:33 ` Michalis Niarchos
2026-08-03 10:43 ` sashiko-bot
2026-08-03 10:33 ` [PATCH 3/4] perf tools: Fix double free and memory leak in kvm_events_record() Michalis Niarchos via B4 Relay
2026-08-03 10:33 ` Michalis Niarchos
2026-08-03 10:43 ` sashiko-bot
2026-08-03 10:33 ` [PATCH 4/4] perf tools: Fix memory leak in cmd_kvm() Michalis Niarchos via B4 Relay
2026-08-03 10:33 ` Michalis Niarchos
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=20260803104207.90A0E1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=michael.niarchos@gmail.com \
--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 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.