public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: accel/amdxdna: Return ERR_PTR on dma_alloc_noncoherent failure
Date: Wed, 25 Mar 2026 07:38:19 +1000	[thread overview]
Message-ID: <review-patch1-20260323173719.2311474-1-lizhi.hou@amd.com> (raw)
In-Reply-To: <20260323173719.2311474-1-lizhi.hou@amd.com>

Patch Review

**Correctness: Correct.**

The commit message clearly explains the problem: `dma_alloc_noncoherent()` returns NULL on failure, but all callers check with `IS_ERR()`. The existing code at lines 63-64 already returns `ERR_PTR(-EINVAL)` for the order check, and line 68 returns the result of `amdxdna_iommu_alloc()` which presumably also returns ERR_PTR on failure. Only the `dma_alloc_noncoherent()` path at line 70-71 was inconsistent.

Confirmed all four call sites use `IS_ERR()`:
- `aie2_message.c:399`: `if (IS_ERR(buff_addr))`
- `aie2_message.c:455`: `if (IS_ERR(addr))`
- `aie2_message.c:1206`: `if (IS_ERR(buf))`
- `aie2_error.c:358`: `if (IS_ERR(events->buf))`

Without this fix, a NULL return from `dma_alloc_noncoherent()` would pass the `IS_ERR()` check (since NULL is not in the ERR_PTR range) and lead to a NULL pointer dereference when the buffer is subsequently used (e.g., at `drm_clflush_virt_range(buff_addr, size)`).

**The fix itself:**
```c
+	vaddr = dma_alloc_noncoherent(xdna->ddev.dev, *size, dma_addr,
+				      DMA_FROM_DEVICE, GFP_KERNEL);
+	if (!vaddr)
+		return ERR_PTR(-ENOMEM);
+
+	return vaddr;
```

This is clean and follows the standard kernel pattern. `-ENOMEM` is the appropriate error code for a DMA allocation failure.

**Minor nits:**
- The Fixes tag references `ece3e8980907` which introduced the `amdxdna_iommu_alloc()` path that created the inconsistency — this is correct.
- The Signed-off-by chain (Wendy Liang as author, Lizhi Hou as submitter) is proper.

**No issues found.**

---
Generated by Claude Code Patch Reviewer

      parent reply	other threads:[~2026-03-24 21:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-23 17:37 [PATCH V1] accel/amdxdna: Return ERR_PTR on dma_alloc_noncoherent failure Lizhi Hou
2026-03-23 17:53 ` Karol Wachowski
2026-03-23 17:56 ` Mario Limonciello (AMD) (kernel.org)
2026-03-23 20:36   ` Lizhi Hou
2026-03-24 21:38 ` Claude review: " Claude Code Review Bot
2026-03-24 21:38 ` 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-20260323173719.2311474-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