From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DC46B3563ED; Mon, 2 Feb 2026 10:07:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770026843; cv=none; b=M5gw0TqLknX1ZghNdqRxGBVDERZPPhSV1oMa74Ev6FsXBx+YPbpHwxLAwBvRWiCmLK1+XViM4tAmMxEOTsJaaYjjK5zXRPMg/Koc99zDlwmCjqcvNNpFF+cAXaSYeCsmWAeNLNBCLxNu8gyCMMSMGJ0Uzbgg/2o/66xzOofHrTc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770026843; c=relaxed/simple; bh=SPlQg0EyU4/DCh7w2oS8RGOQsjsSnbyrEHo3KSL1y1g=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=BWc5re8mhjpI9P7mpVSwJTIG4QxDbHBDzI0Mt/ACpK9tdjLpf2bycuftCxK9YoAbYGIzoc6U+DfSbJwo34CeMKbTsXuZw/ASVTXU/1J1q3KFw4kwfrGaEM0dr0VMElFynbKNBIGF3J/o4W1oSyFko+fS1jh1uMGfksM16HKDOz0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HQK92qyI; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HQK92qyI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4150BC116C6; Mon, 2 Feb 2026 10:07:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1770026843; bh=SPlQg0EyU4/DCh7w2oS8RGOQsjsSnbyrEHo3KSL1y1g=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=HQK92qyIX300LRHc2aMK3ubwx7dgLYNuRzLyUUyPldXvf3QcHTBEDznZO9XmT4/xY CIU2+TouJ8b0UyXd4vzERXzW5Cf/dUF760N11p4gF3cvmqGdeP6kbv4bIv4CmGBiEz CDCnliVNe1XhjJ92SpkO91ctMJIVid5sN0XpQW6xEMqM9ZRi57oVT6jhJCBSG61PPe R4n80mZejwHKCRPr4cKNCtNbgTV/LVPVx//RFH3C/pvvRBkuacSHU2tA3lconM/VEr SyWvAEe6FO1M+FglA7GJxmfGwSWOjAC0xiQefn+pDeRSa4TkXkDF8gUy6JFDJawicR x2altsxN3dX5w== From: Andreas Hindborg To: Daniel Almeida , Oliver Mangold Cc: Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?Q?Bj=C3=B6rn?= Roy Baron , Alice Ryhl , Trevor Gross , Benno Lossin , Danilo Krummrich , Greg Kroah-Hartman , Dave Ertman , Ira Weiny , Leon Romanovsky , "Rafael J. Wysocki" , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Alexander Viro , Christian Brauner , Jan Kara , Lorenzo Stoakes , "Liam R. Howlett" , Viresh Kumar , Nishanth Menon , Stephen Boyd , Bjorn Helgaas , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Paul Moore , Serge Hallyn , Asahi Lina , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-pm@vger.kernel.org, linux-pci@vger.kernel.org, linux-security-module@vger.kernel.org Subject: Re: [PATCH v13 3/4] rust: Add missing SAFETY documentation for `ARef` example In-Reply-To: <06C410F4-8534-43B4-8DE1-039F70B26E5A@collabora.com> References: <20251117-unique-ref-v13-0-b5b243df1250@pm.me> <20251117-unique-ref-v13-3-b5b243df1250@pm.me> <06C410F4-8534-43B4-8DE1-039F70B26E5A@collabora.com> Date: Mon, 02 Feb 2026 10:52:12 +0100 Message-ID: <87tsvzpj5f.fsf@t14s.mail-host-address-is-not-set> Precedence: bulk X-Mailing-List: linux-security-module@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Daniel Almeida writes: >> On 17 Nov 2025, at 07:08, Oliver Mangold wrote: >>=20 >> SAFETY comment in rustdoc example was just 'TODO'. Fixed. >>=20 >> Signed-off-by: Oliver Mangold >> Co-developed-by: Andreas Hindborg >> Signed-off-by: Andreas Hindborg >> --- >> rust/kernel/sync/aref.rs | 10 ++++++---- >> 1 file changed, 6 insertions(+), 4 deletions(-) >>=20 >> diff --git a/rust/kernel/sync/aref.rs b/rust/kernel/sync/aref.rs >> index 4226119d5ac9..937dcf6ed5de 100644 >> --- a/rust/kernel/sync/aref.rs >> +++ b/rust/kernel/sync/aref.rs >> @@ -129,12 +129,14 @@ pub unsafe fn from_raw(ptr: NonNull) -> Self { >> /// # Examples >> /// >> /// ``` >> - /// use core::ptr::NonNull; >> - /// use kernel::sync::aref::{ARef, RefCounted}; >> + /// # use core::ptr::NonNull; >> + /// # use kernel::sync::aref::{ARef, RefCounted}; >> /// >> /// struct Empty {} >> /// >> - /// # // SAFETY: TODO. >> + /// // SAFETY: The `RefCounted` implementation for `Empty` does not= count references and >> + /// // never frees the underlying object. Thus we can act as having= a refcount on the object > > nit: perhaps saying =E2=80=9Can increment on the refcount=E2=80=9D is cle= arer? OK /// // SAFETY: The `RefCounted` implementation for `Empty` does not cou= nt references and never /// // frees the underlying object. Thus we can act as owning an increm= ent on the refcount for /// // the object that we pass to the newly created `ARef`. > >> + /// // that we pass to the newly created `ARef`. >> /// unsafe impl RefCounted for Empty { >> /// fn inc_ref(&self) {} >> /// unsafe fn dec_ref(_obj: NonNull) {} >> @@ -142,7 +144,7 @@ pub unsafe fn from_raw(ptr: NonNull) -> Self { >> /// >> /// let mut data =3D Empty {}; >> /// let ptr =3D NonNull::::new(&mut data).unwrap(); >> - /// # // SAFETY: TODO. >> + /// // SAFETY: We keep `data` around longer than the `ARef`. >> /// let data_ref: ARef =3D unsafe { ARef::from_raw(ptr) }; >> /// let raw_ptr: NonNull =3D ARef::into_raw(data_ref); >> /// >>=20 >> --=20 >> 2.51.2 >>=20 >>=20 >>=20 > > Reviewed-by: Daniel Almeida Thanks. Best regards, Andreas Hindborg