From mboxrd@z Thu Jan 1 00:00:00 1970 From: Claude Code Review Bot 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 Message-ID: In-Reply-To: <20260409001559.622026-3-lyude@redhat.com> References: <20260409001559.622026-1-lyude@redhat.com> <20260409001559.622026-3-lyude@redhat.com> X-Mailer: Claude Code Patch Reviewer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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 `shm= em->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 =3D 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 Rus= t `SGTableMap::drop`), it should either document the precondition that `sgt= ` must be non-NULL, or add a NULL check. Given the destruction-ordering con= cern I describe in patch 4's review, a NULL guard here would be defensive h= ardening. **No pages put:** This function frees the sgt mapping but does not call `dr= m_gem_shmem_put_pages_locked()`. This is intentional =E2=80=94 the pages re= main pinned and are cleaned up when the gem object is ultimately freed =E2= =80=94 but it should be documented explicitly, since `drm_gem_shmem_get_pag= es_sgt_locked` paired `get_pages` with the sgt creation. **Naming:** The double-underscore prefix (`__`) conventionally signals "int= ernal, don't call directly" in the kernel, but this is exported with `EXPOR= T_SYMBOL_GPL` and has a public doc comment. Consider dropping the `__` pref= ix since it's part of the exported API. **Doc comment vs. function name mismatch:** The kerneldoc title says `drm_g= em_shmem_release_sgt_locked` but the function is named `__drm_gem_shmem_fre= e_sgt_locked`. --- --- Generated by Claude Code Patch Reviewer