From: Igor Korotin <igor.korotin@linux.dev>
To: "Nicolás Antinori" <nico.antinori.7@gmail.com>
Cc: "Alice Ryhl" <aliceryhl@google.com>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Benno Lossin" <lossin@kernel.org>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Boqun Feng" <boqun@kernel.org>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Danilo Krummrich" <dakr@kernel.org>,
"Gary Guo" <gary@garyguo.net>, "Miguel Ojeda" <ojeda@kernel.org>,
"Trevor Gross" <tmgross@umich.edu>,
"Onur Özkan" <work@onurozkan.dev>,
linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org
Subject: Re: [PATCH v2] i2c: rust: fix I2cAdapter refcounts double increment
Date: Sat, 30 May 2026 18:09:47 +0100 [thread overview]
Message-ID: <ced4d92f-b2c6-451e-a04f-8ca8a82eab58@linux.dev> (raw)
In-Reply-To: <20260526194734.14378-1-nico.antinori.7@gmail.com>
Hello Nicolás
On 5/26/2026 8:47 PM, Nicolás Antinori wrote:
> // SAFETY: `adapter` is non-null and points to a live `i2c_adapter`.
> // `I2cAdapter` is #[repr(transparent)], so this cast is valid.
> - Ok(unsafe { (&*adapter.as_ptr().cast::<I2cAdapter<device::Normal>>()).into() })
> + Ok(unsafe {
> + ARef::from_raw(NonNull::new_unchecked(
> + adapter.as_ptr().cast::<I2cAdapter<device::Normal>>(),
> + ))
> + })
> }
> }
The `adapter` here is already a NonNull pointer. No need to call
.as_ptr() and then rewrap
with new_unchecked.
Cheers
Igor
prev parent reply other threads:[~2026-05-30 17:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-26 19:47 [PATCH v2] i2c: rust: fix I2cAdapter refcounts double increment Nicolás Antinori
2026-05-30 17:09 ` Igor Korotin [this message]
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=ced4d92f-b2c6-451e-a04f-8ca8a82eab58@linux.dev \
--to=igor.korotin@linux.dev \
--cc=a.hindborg@kernel.org \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=gary@garyguo.net \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=nico.antinori.7@gmail.com \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.