Re: [PATCH] rust: configfs: skip unregister after failed registration
From: Andreas Hindborg
Date: Tue Aug 18 2026 - 05:44:00 EST
"Younes Akhouayri via B4 Relay" <devnull+git.younes.io@xxxxxxxxxx>
writes:
> From: Younes Akhouayri <git@xxxxxxxxx>
>
> Subsystem::new() calls configfs_register_subsystem() from a fallible
> pin_chain callback. If registration fails, ChainPinInit drops the
> already initialized Subsystem. Its PinnedDrop currently calls
> configfs_unregister_subsystem() unconditionally.
>
> configfs_unregister_subsystem() requires registration to have completed
> and immediately dereferences the subsystem dentry. Registering a
> duplicate subsystem name returns -EEXIST before installing that dentry,
> so the cleanup path dereferences NULL and panics the kernel.
>
> Track successful registration explicitly and only unregister in that
> state. Keep mutex destruction unconditional because it is initialized
> before registration.
>
> Fixes: 446cafc295bf ("rust: configfs: introduce rust support for configfs")
> Signed-off-by: Younes Akhouayri <git@xxxxxxxxx>
Reviewed-by: Andreas Hindborg <a.hindborg@xxxxxxxxxx>
Looks good to me, will pick it in a few weeks.
Best regards,
Andreas Hindborg