From: "Benno Lossin" <lossin@kernel.org>
To: "Alice Ryhl" <aliceryhl@google.com>,
"Alexander Viro" <viro@zeniv.linux.org.uk>,
"Jan Kara" <jack@suse.cz>, "Miguel Ojeda" <ojeda@kernel.org>,
"Christian Brauner" <brauner@kernel.org>
Cc: "Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org
Subject: Re: [PATCH] poll: rust: allow poll_table ptrs to be null
Date: Fri, 20 Jun 2025 14:31:22 +0200 [thread overview]
Message-ID: <DARD1ZC0W9QR.3CBLX6RYE65VU@kernel.org> (raw)
In-Reply-To: <20250620-poll-table-null-v1-1-b3fe92a4fd0d@google.com>
On Fri Jun 20, 2025 at 1:49 PM CEST, Alice Ryhl wrote:
> ///
> /// # Safety
> ///
> - /// The caller must ensure that for the duration of `'a`, the pointer will point at a valid poll
> - /// table (as defined in the type invariants).
> - ///
> - /// The caller must also ensure that the `poll_table` is only accessed via the returned
> - /// reference for the duration of `'a`.
> - pub unsafe fn from_ptr<'a>(ptr: *mut bindings::poll_table) -> &'a mut PollTable {
Returning `Option<&'a mut PollTable>` is not an option? I'd like to
avoid wrapping raw pointers...
---
Cheers,
Benno
> - // SAFETY: The safety requirements guarantee the validity of the dereference, while the
> - // `PollTable` type being transparent makes the cast ok.
> - unsafe { &mut *ptr.cast() }
> - }
next prev parent reply other threads:[~2025-06-20 12:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-20 11:49 [PATCH] poll: rust: allow poll_table ptrs to be null Alice Ryhl
2025-06-20 12:31 ` Benno Lossin [this message]
2025-06-20 13:19 ` Alice Ryhl
2025-06-22 7:50 ` Benno Lossin
2025-06-22 7:55 ` Benno Lossin
2025-06-23 11:56 ` Christian Brauner
2025-06-23 13:57 ` Benno Lossin
2025-06-23 13:58 ` Alice Ryhl
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=DARD1ZC0W9QR.3CBLX6RYE65VU@kernel.org \
--to=lossin@kernel.org \
--cc=a.hindborg@kernel.org \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=brauner@kernel.org \
--cc=dakr@kernel.org \
--cc=gary@garyguo.net \
--cc=jack@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
--cc=viro@zeniv.linux.org.uk \
/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;
as well as URLs for NNTP newsgroup(s).