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 v5 05/14] gtrace: Add functions to start/stop tracing on a component path
Date: Mon, 10 Aug 2026 15:33:48 +0000 [thread overview]
Message-ID: <20260810153348.F2A6E1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260810152223.3946743-6-mayuresh.chitale@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] Missing rollback in gtrace_path_start() leaves components in a partially started state on error.
- [High] Early abort in gtrace_path_stop() terminates teardown on the first error, leaving remaining components active.
- [High] Unsafe dereference of gtdrv without NULL check and lockless access to dev->driver can cause a kernel panic or memory corruption.
--
--- Patch [5]: [PATCH v5 05/14] gtrace: Add functions to start/stop tracing on a component path ---
commit 24fa9f699451874fed23109ef92badb57913e17b
Author: Mayuresh Chitale <mayuresh.chitale@oss.qualcomm.com>
gtrace: Add functions to start/stop tracing on a component path
The perf driver framework needs to be able to start / stop all components
in a trace component path during its operation. Add gtrace_path_start()
and gtrace_path_stop() functions for this purpose.
> diff --git a/drivers/hwtracing/gtrace/gtrace-core.c b/drivers/hwtracing/gtrace/gtrace-core.c
> index a89d195ab5b89..6ff1b30879472 100644
> --- a/drivers/hwtracing/gtrace/gtrace-core.c
> +++ b/drivers/hwtracing/gtrace/gtrace-core.c
> @@ -582,6 +582,50 @@ static void gtrace_release_path_nodes(struct gtrace_path *path)
> }
> }
>
> +int gtrace_path_start(struct gtrace_path *path)
> +{
> + const struct gtrace_driver *gtdrv;
> + struct gtrace_component *comp;
> + struct gtrace_path_node *node;
> + int ret;
> +
> + list_for_each_entry_reverse(node, &path->comp_list, head) {
> + comp = node->comp;
> + gtdrv = to_gtrace_driver(comp->dev.driver);
[Severity: High]
Does this code risk a NULL pointer dereference or memory corruption?
If a driver is unbound concurrently, comp->dev.driver could become NULL.
The to_gtrace_driver() macro evaluates its argument twice locklessly:
#define to_gtrace_driver(__drv) \
((__drv) ? container_of_const((__drv), struct gtrace_driver, driver) : NULL)
If comp->dev.driver is set to NULL between the two evaluations,
container_of_const(NULL) returns a bogus negative offset instead of NULL.
Even if it safely returns NULL, there is no NULL check for gtdrv before
dereferencing it on the next line.
> + if (!gtdrv->start)
> + continue;
> +
> + ret = gtdrv->start(comp);
> + if (ret)
> + return ret;
[Severity: High]
If a component fails to start and returns an error here, do we need to
unwind and stop the components that were already successfully started
in previous loop iterations?
Returning immediately leaves the hardware components in a partially started
state, which could lead to hardware inconsistencies, resource leaks, or
unexpected DMA operations.
> + }
> +
> + return 0;
> +}
> +EXPORT_SYMBOL_GPL(gtrace_path_start);
> +
> +int gtrace_path_stop(struct gtrace_path *path)
> +{
> + const struct gtrace_driver *gtdrv;
> + struct gtrace_component *comp;
> + struct gtrace_path_node *node;
> + int ret;
> +
> + list_for_each_entry(node, &path->comp_list, head) {
> + comp = node->comp;
> + gtdrv = to_gtrace_driver(comp->dev.driver);
[Severity: High]
This shares the same risk as gtrace_path_start(). A concurrent driver unbind
or a missing driver could result in gtdrv being NULL or an invalid pointer,
leading to a crash when gtdrv->stop is checked below.
> + if (!gtdrv->stop)
> + continue;
> +
> + ret = gtdrv->stop(comp);
> + if (ret)
> + return ret;
[Severity: High]
If a component fails to stop, is it intentional to abort the entire teardown
sequence early?
Returning on the first error prevents the loop from stopping the remaining
components in the path, leaving downstream components actively running and
consuming hardware resources indefinitely. Should teardown paths use a
best-effort approach to disable as many components as possible?
> + }
> +
> + return 0;
> +}
> +EXPORT_SYMBOL_GPL(gtrace_path_stop);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260810152223.3946743-1-mayuresh.chitale@oss.qualcomm.com?part=5
next prev parent reply other threads:[~2026-08-10 15:33 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 [this message]
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
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=20260810153348.F2A6E1F00A3A@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.