Re: [PATCH v14 11/14] tracing/wprobe: Add set_wprobe and clear_wprobe event triggers
From: sashiko-bot@kernel.org
Date: 2026-08-30 14:52:52
Also in:
linux-perf-users
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] Calling `cancel_work_sync()` on an uninitialized `work_struct` in the error path triggers a kernel warning (WARN_ON). -- commit 5e74cd56c202daf7ad5f60c9e251b2bc86cf21d8 Author: Masami Hiramatsu (Google) [off-list ref] Subject: tracing/wprobe: Add set_wprobe and clear_wprobe event triggers This commit adds set_wprobe and clear_wprobe event triggers to dynamically attach and detach hardware breakpoint address monitoring based on event field contents. Link: https://lore.kernel.org/all/59637b96946653393a7ad3c7de094094796b39c2.1785067572.git.wangjinchao600@gmail.com/ (local)
quoted hunk ↗ jump to hunk
diff --git a/kernel/trace/trace_wprobe.c b/kernel/trace/trace_wprobe.c index 6a11c55e75373..29eae708ae7bc 100644 --- a/kernel/trace/trace_wprobe.c +++ b/kernel/trace/trace_wprobe.c
[ ... ]
quoted hunk ↗ jump to hunk
@@ -199,14 +217,62 @@ static int __register_trace_wprobe(struct trace_wprobe *tw)
[ ... ]
static void free_trace_wprobe(struct trace_wprobe *tw)
{
if (tw) {
+ irq_work_sync(&tw->irq_work);
+ cancel_work_sync(&tw->work);
[Severity: Medium]
Will this trigger a kernel warning in __flush_work() if the work struct has
not been initialized yet?
In alloc_trace_wprobe(), if the kstrdup() allocation for the symbol fails,
the function returns early. Since the tw pointer is managed by the
__free(free_trace_wprobe) guard, it will automatically invoke this cleanup
function:
alloc_trace_wprobe() {
...
tw = kzalloc_flex(*tw, tp.args, nargs);
...
if (symbol) {
tw->symbol = kstrdup(symbol, GFP_KERNEL);
if (!tw->symbol)
return ERR_PTR(-ENOMEM); /* triggers free_trace_wprobe(tw) */
}
...
INIT_WORK(&tw->work, wprobe_work_func);
}
Because the early return happens before INIT_WORK() is called,
cancel_work_sync() will operate on a zeroed work_struct, which can cause a
WARN_ON(!work->func).
trace_probe_cleanup(&tw->tp); kfree(tw->symbol); kfree(tw);
-- Sashiko AI review · https://sashiko.dev/#/patchset/178810001186.64882.2161016469449127450.stgit@devnote2?part=11