Re: [PATCH] rust: drm: gem: shmem: do not leak pages when sg_table() fails
From: Alice Ryhl
Date: Tue Oct 20 2026 - 08:24:53 EST
On Mon, Oct 19, 2026 at 08:21:52PM +0000, Sami Tolvanen wrote:
> `SGTableMap::new()` takes a pages reference and maps the table before
> `Devres::new()` allocates. If the allocation fails, dropping the map
> frees the table but keeps the reference, and the next `sg_table()`
> takes another one. `drm_gem_shmem_release()` puts only one, so the
> pages leak.
>
> Take the pages in the initializer, after the allocation.
>
> Fixes: 616c229ab010 ("rust: drm: gem: Introduce shmem::Object::sg_table()")
> Signed-off-by: Sami Tolvanen <samitolvanen@xxxxxxxxxx>
LGTM:
Cc: stable@xxxxxxxxxxxxxxx
Reviewed-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>
Looks like there might still be another issue when Devres drops
SGTableMap, leaving a handle to the GEM open.
Alice