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] perf build: Fix compiler errors with old capstone
Date: Mon, 06 Jul 2026 23:56:59 +0000	[thread overview]
Message-ID: <20260706235700.53B941F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260706234836.815254-1-namhyung@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Leaked `struct map *` reference in `print_capstone_detail` due to missing `map__put()`.
--

--- Patch [1]: [PATCH v2] perf build: Fix compiler errors with old capstone ---
commit 290412dd8be8c32690d86ead2197a90f8b8eb074
Author: Namhyung Kim <namhyung@kernel.org>

perf build: Fix compiler errors with old capstone

This commit fixes build failures on older capstone versions (prior to v5) by
defining missing RISC-V architectural and mode constants.

> diff --git a/tools/perf/util/capstone.c b/tools/perf/util/capstone.c
> index 5ad537fea4360..0247142a77ba3 100644
> --- a/tools/perf/util/capstone.c
> +++ b/tools/perf/util/capstone.c
> @@ -24,6 +24,13 @@
>  #include "symbol.h"
>  #include "thread.h"
>  
> +#if CS_VERSION_MAJOR < 5
> +#define CS_ARCH_RISCV    15
> +#define CS_MODE_RISCV32  1
> +#define CS_MODE_RISCV64  2
> +#define CS_MODE_RISCVC   4
> +#endif

[ ... ]

Later in tools/perf/util/capstone.c:print_capstone_detail():

> 		if (dso__kernel(map__dso(map))) {
> 			/*
> 			 * The kernel maps can be split into sections, let's
> 			 * find the map first and the search the symbol.
> 			 */
> 			map = maps__find(map__kmaps(map), addr);

[Severity: High]
This isn't a bug introduced by this patch, but does this code leak the map
reference?

When disassembling instructions with X86 memory operands using RIP-relative
addressing, maps__find() returns a new reference to the kernel section map.
Since this new reference is assigned to the local map variable, is there a
missing map__put() before the function returns or the loop continues? This
might lead to a resource leak and reference count imbalance.

> 			if (map == NULL)
> 				continue;
> 		}

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

      reply	other threads:[~2026-07-06 23:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-06 23:48 [PATCH v2] perf build: Fix compiler errors with old capstone Namhyung Kim
2026-07-06 23:56 ` sashiko-bot [this message]

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=20260706235700.53B941F000E9@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