From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: drm/vmwgfx: Change ttm refs for dumb buffers.
Date: Thu, 04 Jun 2026 13:30:07 +1000 [thread overview]
Message-ID: <review-patch4-20260602004203.102901-5-maaz.mombasawala@broadcom.com> (raw)
In-Reply-To: <20260602004203.102901-5-maaz.mombasawala@broadcom.com>
Patch Review
**Status: Has a significant unchecked return value**
**Critical issue — unchecked return value (vmwgfx_surface.c:2332)**:
```c
ttm_base_object_lookup_for_ref(dev_priv->tdev, arg.rep.handle);
```
`ttm_base_object_lookup_for_ref()` returns `struct ttm_base_object *` (or NULL on failure), but the return value is completely discarded. This function is called to acquire an extra reference on the base object that will later be dropped by `vmw_dumb_surface_unref → ttm_base_object_unref`. If the lookup fails and no reference is acquired, the subsequent `ttm_base_object_unref` in `vmw_dumb_surface_unref` will decrement a refcount that was never incremented, causing a refcount underflow and potential use-after-free.
The fix should check the return value:
```c
if (!ttm_base_object_lookup_for_ref(dev_priv->tdev, arg.rep.handle)) {
ret = -EINVAL;
goto err;
}
```
**The dma_buf leak fix in `ttm_prime_fd_to_handle` (ttm_object.c)** is correct and straightforward — the early return was missing a `dma_buf_put()`:
```c
// Before: leaked dma_buf ref on !tdev->ops
if (dma_buf->ops != &tdev->ops)
return -ENOSYS;
// After: properly releases via goto
if (dma_buf->ops != &tdev->ops) {
ret = -ENOSYS;
goto out;
}
```
**The `vmw_dumb_surface_unref` function**: Setting `refcount_release = NULL` is safe because `ttm_release_base()` (ttm_object.c:241) checks for NULL before calling it. The function correctly pairs `ttm_base_object_unref` (drops the base object ref from `lookup_for_ref`) with `vmw_surface_unreference` (drops the resource ref). The ordering is safe since the base object destruction (with NULL release callback) only does IDR cleanup and tfile unref, not memory deallocation.
---
Generated by Claude Code Patch Reviewer
next prev parent reply other threads:[~2026-06-04 3:30 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-02 0:41 [PATCH v5 0/4] Fix some issues from igt runs Maaz Mombasawala
2026-06-02 0:42 ` [PATCH v5 1/4] drm/vmwgfx: Add some checks to vmw_cursor_plane_atomic_update Maaz Mombasawala
2026-06-04 3:30 ` Claude review: " Claude Code Review Bot
2026-06-02 0:42 ` [PATCH v5 2/4] drm/vmwgfx: Check vrefresh in drm_mode_setcrtc Maaz Mombasawala
2026-06-04 3:30 ` Claude review: " Claude Code Review Bot
2026-06-02 0:42 ` [PATCH v5 3/4] drm/vmwgfx: Reserve ttm object before resv usage Maaz Mombasawala
2026-06-04 3:30 ` Claude review: " Claude Code Review Bot
2026-06-02 0:42 ` [PATCH v5 4/4] drm/vmwgfx: Change ttm refs for dumb buffers Maaz Mombasawala
2026-06-04 3:30 ` Claude Code Review Bot [this message]
2026-06-04 3:30 ` Claude review: Fix some issues from igt runs Claude Code Review Bot
-- strict thread matches above, loose matches on Subject: below --
2026-05-21 22:37 [PATCH v4 0/4] " Maaz Mombasawala
2026-05-21 22:37 ` [PATCH v4 4/4] drm/vmwgfx: Change ttm refs for dumb buffers Maaz Mombasawala
2026-05-25 9:32 ` Claude review: " Claude Code Review Bot
2026-05-14 22:48 [PATCH v3 0/5] Fix some issues from igt runs Maaz Mombasawala
2026-05-14 22:48 ` [PATCH v3 4/5] drm/vmwgfx: Change ttm refs for dumb buffers Maaz Mombasawala
2026-05-16 0:17 ` Claude review: " Claude Code Review Bot
2026-05-12 0:27 [PATCH v2 0/5] Fix some issues from igt runs Maaz Mombasawala
2026-05-12 0:27 ` [PATCH v2 4/5] drm/vmwgfx: Change ttm refs for dumb buffers Maaz Mombasawala
2026-05-16 4:26 ` Claude review: " 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-patch4-20260602004203.102901-5-maaz.mombasawala@broadcom.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