Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Mayuresh Chitale" <mayuresh.chitale@oss.qualcomm.com>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v6 13/14] perf tools: Initial support for gtrace decoder
Date: Thu, 01 Oct 2026 05:35:55 +0000	[thread overview]
Message-ID: <20261001053555.675911F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20261001052243.3042627-14-mayuresh.chitale@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] perf: memory leak of gtrace_decoder on duplicate auxtrace info
- [Low] perf: missing explicit <stdbool.h> inclusion for musl compatibility
--

commit fdb0fe6a9d0684b5f29d2d2a91c37ec24db2cc06
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. Actual decoding of the trace payload is not yet
implemented.

> diff --git a/tools/perf/util/gtrace-decoder.c b/tools/perf/util/gtrace-decoder.c
> new file mode 100644
> index 0000000000000..c25fbfc61928d
> --- /dev/null
> +++ b/tools/perf/util/gtrace-decoder.c
> @@ -0,0 +1,95 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Generic hardware trace (gtrace) decoder
> + * Copyright (c) 2026 Qualcomm Technologies, Inc.
> + */
> +
> +#include <errno.h>
> +#include <inttypes.h>
> +#include <stdlib.h>
> +#include <internal/lib.h>
> +#include <linux/zalloc.h>
> +#include "evlist.h"
> +#include "session.h"
> +#include "gtrace.h"

[ ... ]

> +static bool gtrace_evsel_is_auxtrace(struct perf_session *session,
> +				      struct evsel *evsel)
> +{

[Severity: Low]
Does this file need an explicit inclusion of <stdbool.h>?

The gtrace_evsel_is_auxtrace() function signature requires the bool type,
but the file fails to explicitly include <stdbool.h>. This might lead to
build failures on musl libc systems where implicit inclusions differ from
glibc.

> +	struct gtrace_decoder *ptr = container_of(session->auxtrace,
> +						   struct gtrace_decoder, auxtrace);
> +
> +	return evsel->core.attr.type == ptr->pmu_type;
> +}

[ ... ]

> +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]
Can this leak the struct gtrace_decoder pointer?

If perf_event__process_auxtrace_info() processes multiple
PERF_RECORD_AUXTRACE_INFO events for GTRACE (e.g. in a malformed or
concatenated perf.data file), gtrace__process_auxtrace_info() will be
called repeatedly.

Each call allocates a new gtrace_decoder via zalloc() and unconditionally
overwrites session->auxtrace here, without verifying if one was already
present or freeing the previous pointer.

> +
> +	return 0;
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261001052243.3042627-1-mayuresh.chitale@oss.qualcomm.com?part=13

  reply	other threads:[~2026-10-01  5:35 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-01  5:22 [PATCH v6 00/14] Linux RISC-V trace framework and drivers Mayuresh Chitale
2026-10-01  5:22 ` [PATCH v6 01/14] dt-bindings: Add RISC-V trace component bindings Mayuresh Chitale
2026-10-01  5:33   ` sashiko-bot
2026-10-01  5:22 ` [PATCH v6 02/14] hwtracing: gtrace: Initial implementation of gtrace framework Mayuresh Chitale
2026-10-01  5:37   ` sashiko-bot
2026-10-01  5:22 ` [PATCH v6 03/14] gtrace: Add RISC-V platform driver for the " Mayuresh Chitale
2026-10-01  5:36   ` sashiko-bot
2026-10-01  5:22 ` [PATCH v6 04/14] gtrace: Add functions to create/destroy a trace component path Mayuresh Chitale
2026-10-01  5:36   ` sashiko-bot
2026-10-01  5:22 ` [PATCH v6 05/14] gtrace: Add functions to start/stop tracing on a " Mayuresh Chitale
2026-10-01  5:36   ` sashiko-bot
2026-10-01  5:22 ` [PATCH v6 06/14] gtrace: Add RISC-V Trace encoder driver Mayuresh Chitale
2026-10-01  5:34   ` sashiko-bot
2026-10-01  5:22 ` [PATCH v6 07/14] gtrace: Add function to copy into perf AUX buffer Mayuresh Chitale
2026-10-01  5:40   ` sashiko-bot
2026-10-01  5:22 ` [PATCH v6 08/14] perf: Add gtrace AUX buffer trace format type Mayuresh Chitale
2026-10-01  5:22 ` [PATCH v6 09/14] gtrace: Add RISC-V Trace ramsink driver Mayuresh Chitale
2026-10-01  5:42   ` sashiko-bot
2026-10-01  5:22 ` [PATCH v6 10/14] riscv: Enable DMA_RESTRICTED_POOL in defconfig Mayuresh Chitale
2026-10-01  5:22 ` [PATCH v6 11/14] gtrace: Add perf driver for tracing using perf tool Mayuresh Chitale
2026-10-01  5:44   ` sashiko-bot
2026-10-01  5:22 ` [PATCH v6 12/14] perf tools: Add RISC-V trace PMU record capabilities Mayuresh Chitale
2026-10-01  5:22 ` [PATCH v6 13/14] perf tools: Initial support for gtrace decoder Mayuresh Chitale
2026-10-01  5:35   ` sashiko-bot [this message]
2026-10-01  5:22 ` [PATCH v6 14/14] MAINTAINERS: Add entry for RISC-V trace framework 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=20261001053555.675911F000FF@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox