From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: accel/amdxdna: Remove drv_cmd tracing from job free callback
Date: Thu, 04 Jun 2026 16:19:39 +1000 [thread overview]
Message-ID: <review-patch1-20260529152837.1973405-1-lizhi.hou@amd.com> (raw)
In-Reply-To: <20260529152837.1973405-1-lizhi.hou@amd.com>
Patch Review
**Correctness: Good.** The use-after-free is real. The callers in `aie2_hwctx_cfg_debug_bo()` and `aie2_hwctx_sync_debug_bo()` pass a pointer to a stack-local `struct amdxdna_drv_cmd cmd`:
```c
struct amdxdna_drv_cmd cmd = { 0 };
...
ret = amdxdna_cmd_submit(client, &cmd, ...);
```
And in `amdxdna_cmd_submit()` this is stored as a bare pointer:
```c
job->drv_cmd = drv_cmd;
```
Since `aie2_sched_job_free` runs asynchronously via `drm_sched_backend_ops.free_job`, it can execute after the caller's stack frame is gone, making `job->drv_cmd` a dangling pointer. The fix correctly removes the access.
**Minor observation:** The added comment says `/* job->drv_cmd could be freed, so use DEFAULT_IO */`, but strictly speaking `drv_cmd` points to a stack-local — it isn't "freed" in the heap sense, the stack frame just goes out of scope. A more precise comment might say "could be invalid" or "may point to freed/stale memory." This is very minor and doesn't affect the fix.
**Other `drv_cmd` accesses:** The other uses of `job->drv_cmd` in `aie2_ctx.c` (the "signaling fence" trace at line 212, "job run" at line 384, the switch at line 395, and "sent to device" at line 429) all happen within `aie2_sched_job_run()` or its signal callback path, which runs while the job is actively submitted — the caller is blocked in `aie2_cmd_wait()` at that point, so the stack-local `cmd` is still valid. Those accesses are fine.
**Reviewed-by criteria:** This is a clean, minimal fix for a real bug. No concerns.
---
Generated by Claude Code Patch Reviewer
prev parent reply other threads:[~2026-06-04 6:19 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-29 15:28 [PATCH V1] accel/amdxdna: Remove drv_cmd tracing from job free callback Lizhi Hou
2026-05-31 14:18 ` Mario Limonciello
2026-06-01 15:18 ` Lizhi Hou
2026-06-03 18:34 ` Mario Limonciello
2026-06-03 20:17 ` Lizhi Hou
2026-06-04 6:19 ` Claude review: " Claude Code Review Bot
2026-06-04 6:19 ` Claude Code Review 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=review-patch1-20260529152837.1973405-1-lizhi.hou@amd.com \
--to=claude-review@example.com \
--cc=dri-devel-reviews@example.com \
/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