Re: [PATCH v2 7/7] rust: drm: make Driver::File lifetime-parameterized

From: Alice Ryhl

Date: Sat Nov 07 2026 - 03:17:13 EST


On Sat, Nov 07, 2026 at 03:03:25AM +0100, Danilo Krummrich wrote:
> + // Run driver destructors without `filelist_mutex`. Take each link before dropping its
> + // allocation to avoid recursively dropping the entire chain.
> + while let Some(mut data) = files {
> + files = data.as_mut().project().next.take();
> + drop(data);
> + drm.open_count.fetch_sub(1, Release);
> + }

Instead of transferring all the files to another linked list, how about
taking them off the file list one-by-one? If you release the mutex in
between dropping each file, then we still avoid deadlocks if the file
private data destructor takes the lock.

Alice