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 v2 1/6] perf kvm: Factor out kvm_need_default_arch_event()
Date: Tue, 23 Jun 2026 21:20:06 +0000	[thread overview]
Message-ID: <20260623212007.4085D1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260623191439.3621593-2-namhyung@kernel.org>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] Silent error suppression on memory allocation failure in kvm_need_default_arch_event()
- [Low] Missing POSIX standard header <stdlib.h> for calloc() and free() in kvm-stat.c
--

commit 79c29a62706a76c9c3a62f6592977712a8f8b5fd
Author: Namhyung Kim <namhyung@kernel.org>

perf kvm: Factor out kvm_need_default_arch_event()

The kvm_add_default_arch_event() has a similar logic in each arch to
check if there's an existing command line option for events.  Let's
check it in the generic code and remove the duplication.

> diff --git a/tools/perf/util/kvm-stat.c b/tools/perf/util/kvm-stat.c
> index 755ab659a05c3..c571d2ed711a8 100644
> --- a/tools/perf/util/kvm-stat.c
> +++ b/tools/perf/util/kvm-stat.c
> @@ -1,8 +1,10 @@
>  // SPDX-License-Identifier: GPL-2.0
>  #include "debug.h"
> +#include "env.h"
>  #include "evsel.h"
>  #include "kvm-stat.h"
>  #include <dwarf-regs.h>
> +#include <subcmd/parse-options.h>

[Severity: Low]
Should <stdlib.h> be explicitly included here for calloc() and free() used
later in this file?

Relying on implicit inclusions can lead to compilation failures when building
the perf tool against musl libc.

[ ... ]

> +	/* parse_options() may change the argv, let's make a copy */
> +	tmp_argv = calloc(argc + 1, sizeof(char *));
> +	if (!tmp_argv)
> +		return false;

[Severity: Medium]
Is it intended to silently swallow the allocation error here and return false?

If calloc() fails, returning false conflates a memory allocation failure with
the logical state of the default arch event not being needed. While the caller
might fail on a subsequent allocation, would it be better to propagate the
error so memory pressure conditions are explicitly caught?

[ ... ]

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

  reply	other threads:[~2026-06-23 21:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-23 19:14 [PATCH v2 0/6] perf kvm: A small update in the default arch event Namhyung Kim
2026-06-23 19:14 ` [PATCH v2 1/6] perf kvm: Factor out kvm_need_default_arch_event() Namhyung Kim
2026-06-23 21:20   ` sashiko-bot [this message]
2026-06-23 19:14 ` [PATCH v2 2/6] perf kvm: Check kvm_need_default_arch_event() early Namhyung Kim
2026-06-23 19:14 ` [PATCH v2 3/6] perf kvm: Kill STRDUP_FAIL_EXIT() Namhyung Kim
2026-06-23 19:14 ` [PATCH v2 4/6] perf kvm: Do not copy filename string Namhyung Kim
2026-06-23 21:46   ` sashiko-bot
2026-06-23 19:14 ` [PATCH v2 5/6] perf kvm: Fix a memory leak in the usage string Namhyung Kim
2026-06-23 19:14 ` [PATCH v2 6/6] perf test: Simplify perf kvm record/report tests Namhyung Kim
2026-06-23 21:57   ` sashiko-bot

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=20260623212007.4085D1F000E9@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