Re: [PATCH] rust_binderfs: fix minor number leak on binder-control creation failure

From: Alice Ryhl

Date: Thu Nov 26 2026 - 02:58:46 EST


On Mon, Nov 02, 2026 at 08:15:32PM +0530, Adhyansh Verma wrote:
> In binderfs_binder_ctl_create(), a minor number is reserved using
> ida_alloc_max(). If d_alloc_name() subsequently fails (e.g. under memory
> pressure), the function jumps to the error path.
>
> However, the cleanup path only calls kfree(device) and iput(inode).
> Because inode->i_private has not yet been set to device, the eviction
> handler binderfs_evict_inode() returns early without freeing the minor
> number. Consequently, the reserved minor number is permanently leaked
> from the global binderfs_minors IDA.
>
> Fix this by introducing proper error unwind labels so that the allocated
> minor number is released via ida_free() under binderfs_minors_mutex if
> dentry allocation fails.
>
> Fixes: eafedbc7c050 ("rust_binder: add Rust Binder driver")
> Signed-off-by: Adhyansh Verma <adhyanshverma2010@xxxxxxxxx>

Reviewed-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>