Re: [PATCH] rust: drm: fix unsound initialization in drm::Device::new

From: Danilo Krummrich

Date: Tue Apr 28 2026 - 10:14:51 EST


On Tue Apr 28, 2026 at 2:20 PM CEST, Eliot Courtney wrote:
> If pinned initialization of drm::Device::Data fails, it calls
> drm::Device::release via drm_dev_put. This materializes a reference to
> &drm::Device, but it's not fully constructed yet, because initializing
> `data` failed. It should not be dropped either. Instead, if pinned
> initialization fails, make sure drm::Device::release isn't called.
>
> Fixes: 2e9fdbe5ec7a ("rust: drm: device: drop_in_place() the drm::Device in release()")
> Signed-off-by: Eliot Courtney <ecourtney@xxxxxxxxxx>

There's already a patch from Lyude for this [1].

That said, I like the approach with the ALLOC_VTABLE.

@Lyude: Do you mind if we pick Eliot's patch?

Thanks,
Danilo

[1] https://lore.kernel.org/lkml/20260320233645.950190-2-lyude@xxxxxxxxxx/