Re: [PATCH] rust: configfs: skip unregister after failed registration
Andreas Hindborg <[email protected]>
| Newsgroups | org.kernel.vger.rust-for-linux,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
"Younes Akhouayri via B4 Relay" <[email protected]> writes: > From: Younes Akhouayri <[email protected]> > > 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 <[email protected]> Reviewed-by: Andreas Hindborg <[email protected]> Looks good to me, will pick it in a few weeks. Best regards, Andreas Hindborg