From: sashiko-bot@kernel.org
To: "Mayuresh Chitale" <mayuresh.chitale@oss.qualcomm.com>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH v5 13/14] perf tools: Initial support for gtrace decoder
Date: Mon, 10 Aug 2026 15:51:18 +0000 [thread overview]
Message-ID: <20260810155119.DA6D21F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260810152223.3946743-14-mayuresh.chitale@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] Missing explicit header inclusions for free() and zalloc(), leading to musl compatibility failures and pointer truncation.
- [Medium] Unconditionally overwriting `session->auxtrace` causes a memory leak on multiple `PERF_RECORD_AUXTRACE_INFO` events.
--
--- Patch [13]: [PATCH v5 13/14] perf tools: Initial support for gtrace decoder ---
commit 7c1bf67a1a25514ab10564a3e48db1965dbac1a8
Author: Mayuresh Chitale <mayuresh.chitale@oss.qualcomm.com>
perf tools: Initial support for gtrace decoder
Add bare bones support for gtrace decoder so that the data received
from the hardware by the gtrace perf driver can be written to the
perf record output file.
> diff --git a/tools/perf/util/gtrace-decoder.c b/tools/perf/util/gtrace-decoder.c
> new file mode 100644
> index 0000000000000..4a1571431edb3
> --- /dev/null
> +++ b/tools/perf/util/gtrace-decoder.c
> @@ -0,0 +1,93 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Generic hardware trace (gtrace) decoder
> + * Copyright (c) 2026 Qualcomm Technologies, Inc.
> + */
> +
> +#include <errno.h>
> +#include <inttypes.h>
> +#include <internal/lib.h>
> +#include "evlist.h"
> +#include "session.h"
> +#include "gtrace.h"
[Severity: Medium]
Are we missing some explicit header inclusions here?
The code uses free() and zalloc() further down in the file, but does not
include <stdlib.h> or <linux/zalloc.h>.
Missing <stdlib.h> can cause compilation failures under musl.
Missing <linux/zalloc.h> can cause zalloc() to be implicitly declared as
returning an int. On 64-bit systems, this truncates the upper 32 bits of
the pointer, which can lead to a segmentation fault when dereferenced.
[ ... ]
> +int gtrace__process_auxtrace_info(union perf_event *event,
> + struct perf_session *session)
> +{
> + struct perf_record_auxtrace_info *auxtrace_info = &event->auxtrace_info;
> + struct gtrace_decoder *ptr;
> +
> + if (auxtrace_info->header.size < GTRACE_AUXTRACE_PRIV_SIZE +
> + sizeof(struct perf_record_auxtrace_info))
> + return -EINVAL;
> +
> + ptr = zalloc(sizeof(*ptr));
> + if (!ptr)
> + return -ENOMEM;
> +
> + ptr->session = session;
> + ptr->machine = &session->machines.host;
> + ptr->auxtrace_type = auxtrace_info->type;
> + ptr->pmu_type = auxtrace_info->priv[0];
> +
> + ptr->auxtrace.process_event = gtrace_process_event;
> + ptr->auxtrace.process_auxtrace_event = gtrace_process_auxtrace_event;
> + ptr->auxtrace.flush_events = gtrace_flush;
> + ptr->auxtrace.free_events = gtrace_free_events;
> + ptr->auxtrace.free = gtrace_free;
> + ptr->auxtrace.evsel_is_auxtrace = gtrace_evsel_is_auxtrace;
> + session->auxtrace = &ptr->auxtrace;
[Severity: Medium]
Could this leak the previously allocated decoder context if multiple
PERF_RECORD_AUXTRACE_INFO events are processed?
It looks like session->auxtrace is unconditionally overwritten here without
checking or freeing any structure that was already allocated.
> +
> + return 0;
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260810152223.3946743-1-mayuresh.chitale@oss.qualcomm.com?part=13
next prev parent reply other threads:[~2026-08-10 15:51 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-10 15:22 [PATCH v5 00/14] Linux RISC-V trace framework and drivers Mayuresh Chitale
2026-08-10 15:22 ` Mayuresh Chitale
2026-08-10 15:22 ` [PATCH v5 01/14] dt-bindings: Add RISC-V trace component bindings Mayuresh Chitale
2026-08-10 15:22 ` Mayuresh Chitale
2026-08-10 15:33 ` sashiko-bot
2026-08-10 15:22 ` [PATCH v5 02/14] hwtracing: gtrace: Initial implementation of gtrace framework Mayuresh Chitale
2026-08-10 15:22 ` Mayuresh Chitale
2026-08-10 15:36 ` sashiko-bot
2026-08-10 15:22 ` [PATCH v5 03/14] gtrace: Add RISC-V platform driver for the " Mayuresh Chitale
2026-08-10 15:22 ` Mayuresh Chitale
2026-08-10 15:38 ` sashiko-bot
2026-08-10 15:22 ` [PATCH v5 04/14] gtrace: Add functions to create/destroy a trace component path Mayuresh Chitale
2026-08-10 15:22 ` Mayuresh Chitale
2026-08-10 15:34 ` sashiko-bot
2026-08-10 15:22 ` [PATCH v5 05/14] gtrace: Add functions to start/stop tracing on a " Mayuresh Chitale
2026-08-10 15:22 ` Mayuresh Chitale
2026-08-10 15:33 ` sashiko-bot
2026-08-10 15:22 ` [PATCH v5 06/14] gtrace: Add RISC-V Trace encoder driver Mayuresh Chitale
2026-08-10 15:22 ` Mayuresh Chitale
2026-08-10 15:40 ` sashiko-bot
2026-08-10 15:22 ` [PATCH v5 07/14] gtrace: Add function to copy into perf AUX buffer Mayuresh Chitale
2026-08-10 15:22 ` Mayuresh Chitale
2026-08-10 15:42 ` sashiko-bot
2026-08-10 15:22 ` [PATCH v5 08/14] perf: Add gtrace AUX buffer trace format type Mayuresh Chitale
2026-08-10 15:22 ` Mayuresh Chitale
2026-08-10 15:37 ` sashiko-bot
2026-08-10 15:22 ` [PATCH v5 09/14] gtrace: Add RISC-V Trace ramsink driver Mayuresh Chitale
2026-08-10 15:22 ` Mayuresh Chitale
2026-08-10 15:47 ` sashiko-bot
2026-08-10 15:22 ` [PATCH v5 10/14] riscv: Enable DMA_RESTRICTED_POOL in defconfig Mayuresh Chitale
2026-08-10 15:22 ` Mayuresh Chitale
2026-08-10 15:22 ` [PATCH v5 11/14] gtrace: Add perf driver for tracing using perf tool Mayuresh Chitale
2026-08-10 15:22 ` Mayuresh Chitale
2026-08-10 15:48 ` sashiko-bot
2026-08-10 15:22 ` [PATCH v5 12/14] perf tools: Add RISC-V trace PMU record capabilities Mayuresh Chitale
2026-08-10 15:22 ` Mayuresh Chitale
2026-08-10 15:55 ` sashiko-bot
2026-08-10 15:22 ` [PATCH v5 13/14] perf tools: Initial support for gtrace decoder Mayuresh Chitale
2026-08-10 15:22 ` Mayuresh Chitale
2026-08-10 15:51 ` sashiko-bot [this message]
2026-08-10 15:22 ` [PATCH v5 14/14] MAINTAINERS: Add entry for RISC-V trace framework Mayuresh Chitale
2026-08-10 15:22 ` Mayuresh Chitale
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=20260810155119.DA6D21F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=mayuresh.chitale@oss.qualcomm.com \
--cc=robh@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 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.