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: drm/gem/shmem: Introduce __drm_gem_shmem_free_sgt_locked()
Date: Sun, 12 Apr 2026 12:01:18 +1000	[thread overview]
Message-ID: <review-patch2-20260409001559.622026-3-lyude@redhat.com> (raw)
In-Reply-To: <20260409001559.622026-3-lyude@redhat.com>

Patch Review

This extracts the sgt teardown logic into a standalone function and exports it for the Rust bindings.

**Missing NULL-safety:** The new function unconditionally dereferences `shmem->sgt`:

```c
void __drm_gem_shmem_free_sgt_locked(struct drm_gem_shmem_object *shmem)
{
	dma_resv_assert_held(shmem->base.resv);

	dma_unmap_sgtable(shmem->base.dev->dev, shmem->sgt, DMA_BIDIRECTIONAL, 0);
	sg_free_table(shmem->sgt);
	kfree(shmem->sgt);
	shmem->sgt = NULL;
}
```

The caller in `drm_gem_shmem_release` guards with `if (shmem->sgt)`, so the internal use is fine. But as an exported function (and one called from Rust `SGTableMap::drop`), it should either document the precondition that `sgt` must be non-NULL, or add a NULL check. Given the destruction-ordering concern I describe in patch 4's review, a NULL guard here would be defensive hardening.

**No pages put:** This function frees the sgt mapping but does not call `drm_gem_shmem_put_pages_locked()`. This is intentional — the pages remain pinned and are cleaned up when the gem object is ultimately freed — but it should be documented explicitly, since `drm_gem_shmem_get_pages_sgt_locked` paired `get_pages` with the sgt creation.

**Naming:** The double-underscore prefix (`__`) conventionally signals "internal, don't call directly" in the kernel, but this is exported with `EXPORT_SYMBOL_GPL` and has a public doc comment. Consider dropping the `__` prefix since it's part of the exported API.

**Doc comment vs. function name mismatch:** The kerneldoc title says `drm_gem_shmem_release_sgt_locked` but the function is named `__drm_gem_shmem_free_sgt_locked`.

---

---
Generated by Claude Code Patch Reviewer

  parent reply	other threads:[~2026-04-12  2:01 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-09  0:12 [PATCH v10 0/5] Rust bindings for gem shmem Lyude Paul
2026-04-09  0:12 ` [PATCH v10 1/5] rust: drm: gem: s/device::Device/Device/ for shmem.rs Lyude Paul
2026-04-10  7:54   ` Alexandre Courbot
2026-04-12  2:01   ` Claude review: " Claude Code Review Bot
2026-04-09  0:12 ` [PATCH v10 2/5] drm/gem/shmem: Introduce __drm_gem_shmem_free_sgt_locked() Lyude Paul
2026-04-10  7:54   ` Alexandre Courbot
2026-04-12  2:01   ` Claude Code Review Bot [this message]
2026-04-09  0:12 ` [PATCH v10 3/5] drm/gem/shmem: Export drm_gem_shmem_get_pages_sgt_locked() Lyude Paul
2026-04-10  7:55   ` Alexandre Courbot
2026-04-12  2:01   ` Claude review: " Claude Code Review Bot
2026-04-09  0:12 ` [PATCH v10 4/5] rust: drm: gem: Introduce shmem::SGTable Lyude Paul
2026-04-09 22:57   ` Deborah Brouwer
2026-04-10  7:55   ` Alexandre Courbot
2026-04-12  2:01   ` Claude review: " Claude Code Review Bot
2026-04-09  0:12 ` [PATCH v10 5/5] rust: drm: gem: Add vmap functions to shmem bindings Lyude Paul
2026-04-11 13:32   ` Alexandre Courbot
2026-04-12  2:01   ` Claude review: " Claude Code Review Bot
2026-04-12  2:01 ` Claude review: Rust bindings for gem shmem 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-20260409001559.622026-3-lyude@redhat.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