From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: drm/tegra: Fix iommu_map_sgtable() return value check
Date: Thu, 23 Apr 2026 08:57:24 +1000 [thread overview]
Message-ID: <review-patch2-20260421-iommu_map_sgtable-return-v1-2-fb484c07d2a1@nvidia.com> (raw)
In-Reply-To: <20260421-iommu_map_sgtable-return-v1-2-fb484c07d2a1@nvidia.com>
Patch Review
**Status: Good**
This patch introduces a local `ssize_t size` to capture the return value, checks `< 0`, and only assigns to `bo->size` on success:
```c
+ size = iommu_map_sgtable(tegra->domain, bo->iova, bo->sgt, prot);
+ if (size < 0) {
dev_err(tegra->drm->dev, "failed to map buffer\n");
- err = -ENOMEM;
+ err = size;
goto remove;
}
+
+ bo->size = size;
```
The deferral of `bo->size = size` to after the error check is a nice improvement -- the old code would write zero into `bo->size` on the error path (since it checked `!bo->size`), which was harmless but sloppy. Now `bo->size` is only set on success.
One minor note: `bo->size` is declared as `size_t` in `gem.h:68`. Assigning from `ssize_t` to `size_t` is safe here because it only happens after the `< 0` check, so the value is guaranteed non-negative. This is fine.
Similarly, `err = size` narrows `ssize_t` to `int` but only on the error path (negative errno), which is safe.
No issues.
---
Generated by Claude Code Patch Reviewer
next prev parent reply other threads:[~2026-04-22 22:57 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-21 4:02 [PATCH 0/4] Fix checking of iommu_map_sgtable return value Mikko Perttunen
2026-04-21 4:02 ` [PATCH 1/4] gpu: host1x: Fix iommu_map_sgtable() return value check Mikko Perttunen
2026-04-22 22:57 ` Claude review: " Claude Code Review Bot
2026-04-21 4:02 ` [PATCH 2/4] drm/tegra: " Mikko Perttunen
2026-04-22 22:57 ` Claude Code Review Bot [this message]
2026-04-21 4:02 ` [PATCH 3/4] drm/msm: Fix iommu_map_sgtable() return value check and avoid WARN Mikko Perttunen
2026-04-22 22:57 ` Claude review: " Claude Code Review Bot
2026-04-21 4:02 ` [PATCH 4/4] media: nvidia: tegra-vde: Fix iommu_map_sgtable() return value check Mikko Perttunen
2026-04-22 22:57 ` Claude review: " Claude Code Review Bot
2026-04-22 22:57 ` Claude review: Fix checking of iommu_map_sgtable return value Claude Code Review Bot
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-patch2-20260421-iommu_map_sgtable-return-v1-2-fb484c07d2a1@nvidia.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