mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andreas Hindborg <a.hindborg@kernel.org>
To: "Younes Akhouayri via B4 Relay"
	<devnull+git.younes.io@kernel.org>,
	"Breno Leitao" <leitao@debian.org>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"Daniel Almeida" <daniel.almeida@collabora.com>,
	"Tamir Duberstein" <tamird@kernel.org>,
	"Alexandre Courbot" <acourbot@nvidia.com>,
	"Onur Özkan" <work@onurozkan.dev>
Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
	Younes Akhouayri <git@younes.io>
Subject: Re: [PATCH] rust: configfs: skip unregister after failed registration
Date: Tue, 18 Aug 2026 12:09:40 +0200	[thread overview]
Message-ID: <87wltn91uj.fsf@t14s.mail-host-address-is-not-set> (raw)
In-Reply-To: <87zeyj93cw.fsf@t14s.mail-host-address-is-not-set>

Andreas Hindborg <a.hindborg@kernel.org> writes:

> "Younes Akhouayri via B4 Relay" <devnull+git.younes.io@kernel.org>
> writes:
>
>> From: Younes Akhouayri <git@younes.io>
>>
>> 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@younes.io>
>
>
> Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org>
>
> Looks good to me, will pick it in a few weeks.

Actually, we do not need the `as_mut` call:

diff --git a/rust/kernel/configfs.rs b/rust/kernel/configfs.rs
index fce994e7f8b8..62fd2d458a1c 100644
--- a/rust/kernel/configfs.rs
+++ b/rust/kernel/configfs.rs
@@ -176,12 +176,12 @@ pub fn new(
             data <- data,
             registered: false,
         })
-        .pin_chain(|mut this| {
+        .pin_chain(|this| {
             crate::error::to_result(
                 // SAFETY: We initialized `this.subsystem` according to C API contract above.
                 unsafe { bindings::configfs_register_subsystem(this.subsystem.get()) },
             )?;
-            *this.as_mut().project().registered = true;
+            *this.project().registered = true;
             Ok(())
         })
     }


Best regards,
Andreas Hindborg



  reply	other threads:[~2026-08-18 10:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <8L_eiohtkr-KVK8wOx5hbz_bo8XmfV8FHHX0zNjlG9RROwHwX_qm_KwmORgQkKq0k06TyMCArt_3HoW5QoGM4A==@protonmail.internalid>
2026-08-18  8:11 ` Younes Akhouayri via B4 Relay
2026-08-18  9:37   ` Andreas Hindborg
2026-08-18 10:09     ` Andreas Hindborg [this message]
2026-08-18 10:49   ` Gary Guo
2026-08-18 10:53     ` Andreas Hindborg
2026-08-18 11:00       ` Gary Guo
2026-08-18 12:24         ` Andreas Hindborg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wltn91uj.fsf@t14s.mail-host-address-is-not-set \
    --to=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=dakr@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=devnull+git.younes.io@kernel.org \
    --cc=gary@garyguo.net \
    --cc=git@younes.io \
    --cc=leitao@debian.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tamird@kernel.org \
    --cc=tmgross@umich.edu \
    --cc=work@onurozkan.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®