From: sashiko-bot@kernel.org
To: "Andreas Hindborg" <a.hindborg@kernel.org>
Cc: linux-pci@vger.kernel.org, ojeda@kernel.org,
dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v18 1/8] rust: alloc: add `KBox::into_non_null`
Date: Thu, 25 Jun 2026 10:22:06 +0000 [thread overview]
Message-ID: <20260625102207.1DF121F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260625-unique-ref-v18-1-4e06b5896d47@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Mismatch between SAFETY comment and executed code in `into_non_null`.
--
commit c2c9f847b4c97663dbc3f96c92652dbd5698f0aa
Author: Andreas Hindborg <a.hindborg@kernel.org>
rust: alloc: add KBox::into_non_null
This commit adds an into_non_null() method to Box<T, A> that consumes the box
and returns a NonNull<T>. It acts as a convenience wrapper around
Self::into_raw() for callers requiring a NonNull pointer.
> diff --git a/rust/kernel/alloc/kbox.rs b/rust/kernel/alloc/kbox.rs
> index 35d1e015848dd..d534e8adcf7b3 100644
> --- a/rust/kernel/alloc/kbox.rs
> +++ b/rust/kernel/alloc/kbox.rs
[ ... ]
> @@ -211,6 +211,15 @@ pub fn leak<'a>(b: Self) -> &'a mut T {
> // which points to an initialized instance of `T`.
> unsafe { &mut *Box::into_raw(b) }
> }
> +
> + /// Consumes the `Box<T,A>` and returns a `NonNull<T>`.
> + ///
> + /// Like [`Self::into_raw`], but returns a `NonNull`.
> + #[inline]
> + pub fn into_non_null(b: Self) -> NonNull<T> {
> + // SAFETY: `KBox::into_raw` returns a valid pointer.
> + unsafe { NonNull::new_unchecked(Self::into_raw(b)) }
[Severity: Low]
This isn't a bug, but there is a mismatch between the safety comment and the
executed code in into_non_null(). The safety comment specifies KBox::into_raw,
but the code executes Self::into_raw(b) on the generic Box<T, A>.
Would it be better for the comment to reference the actual generic type method
being called to prevent reader confusion?
> + }
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260625-unique-ref-v18-0-4e06b5896d47@kernel.org?part=1
next prev parent reply other threads:[~2026-06-25 10:22 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-25 10:15 [PATCH v18 0/8] rust: add `Ownable` trait and `Owned` type Andreas Hindborg
2026-06-25 10:15 ` [PATCH v18 1/8] rust: alloc: add `KBox::into_non_null` Andreas Hindborg
2026-06-25 10:22 ` sashiko-bot [this message]
2026-06-25 10:15 ` [PATCH v18 2/8] rust: types: Add Ownable/Owned types Andreas Hindborg
2026-06-25 10:24 ` sashiko-bot
2026-06-25 12:24 ` Andreas Hindborg
2026-06-25 10:15 ` [PATCH v18 3/8] rust: implement `ForeignOwnable` for `Owned` Andreas Hindborg
2026-06-25 10:23 ` sashiko-bot
2026-06-25 13:29 ` Gary Guo
2026-06-25 19:47 ` Andreas Hindborg
2026-06-25 10:15 ` [PATCH v18 4/8] rust: page: convert to `Ownable` Andreas Hindborg
2026-06-25 10:25 ` sashiko-bot
2026-06-25 13:32 ` Gary Guo
2026-06-25 10:15 ` [PATCH v18 5/8] rust: rename `AlwaysRefCounted` to `RefCounted` Andreas Hindborg
2026-06-25 10:28 ` sashiko-bot
2026-06-25 12:26 ` Andreas Hindborg
2026-06-25 10:15 ` [PATCH v18 6/8] rust: Add missing SAFETY documentation for `ARef` example Andreas Hindborg
2026-06-25 10:21 ` sashiko-bot
2026-06-25 10:15 ` [PATCH v18 7/8] rust: Add `OwnableRefCounted` Andreas Hindborg
2026-06-25 10:26 ` sashiko-bot
2026-06-25 12:37 ` Andreas Hindborg
2026-06-25 10:15 ` [PATCH v18 8/8] rust: page: add `from_raw()` Andreas Hindborg
2026-06-25 10:25 ` sashiko-bot
2026-06-25 13:02 ` 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=20260625102207.1DF121F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=a.hindborg@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-pci@vger.kernel.org \
--cc=ojeda@kernel.org \
--cc=sashiko-reviews@lists.linux.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