Re: [PATCH] rust: configfs: fix release safety documentation

From: Andreas Hindborg

Date: Wed Jul 08 2026 - 02:44:51 EST


"Yilin Chen" <1479826151@xxxxxx> writes:

> The old Safety docs of ItemOperationsVTable<Group<Data>, Data>::release()
> described this as a config_group pointer embedded in Group<Parent>.
>
> But the inner code implies the implementation first gets the containing
> config_group pointer through the cg_item field. It then gets Group<Data>
> pointer from that group pointer.
>
> The new Safety docs fix this by describing the actual pointer chain and
> concrete Group<Data> type, not Group<Parent>.
>
> Assisted-by: Codex:GPT-5
> Signed-off-by: Yilin Chen <1479826151@xxxxxx>
> ---
> rust/kernel/configfs.rs | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/rust/kernel/configfs.rs b/rust/kernel/configfs.rs
> index 2339c6467..2ac75c628 100644
> --- a/rust/kernel/configfs.rs
> +++ b/rust/kernel/configfs.rs
> @@ -437,8 +437,10 @@ impl<Data> ItemOperationsVTable<Group<Data>, Data>
> {
> /// # Safety
> ///
> - /// `this` must be a pointer to a `bindings::config_group` embedded in a
> - /// `Group<Parent>`.
> + /// `this` must be a valid pointer to the `bindings::config_item` embedded in
> + /// the `cg_item` field of a `bindings::config_group`.
> + ///
> + /// That `bindings::config_group` must be embedded in a `Group<Data>`.
> ///
> /// This function will destroy the pointee of `this`. The pointee of `this`
> /// must not be accessed after the function returns.

I think it should also be `Group<Data>` instead of `Group<Parent>`.

How about:

`this` must be a pointer to the `cg_item` field of a
`bindings::config_group` embedded in a valid `Group<Data>`.


Best regards,
Andreas Hindborg