From: spidermana <xuyiwen14@gmail.com>
To: mehmet.mkoseoglu@gmail.com
Cc: a.hindborg@kernel.org, acourbot@nvidia.com, aliceryhl@google.com,
bjorn3_gh@protonmail.com, boqun@kernel.org, dakr@kernel.org,
daniel.almeida@collabora.com, gary@garyguo.net,
linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
lossin@kernel.org, ojeda@kernel.org, rafael@kernel.org,
rust-for-linux@vger.kernel.org, tamird@kernel.org,
tmgross@umich.edu, viresh.kumar@linaro.org, work@onurozkan.dev
Subject: Re: [PATCH v3] rust: cpufreq: reject NULL from cpufreq_cpu_get()
Date: Mon, 28 Sep 2026 18:22:14 +0200 [thread overview]
Message-ID: <20260928162214.487564-1-xuyiwen14@gmail.com> (raw)
In-Reply-To: <20260829161013.102967-1-mehmet.mkoseoglu@gmail.com>
On Sat, 29 Aug 2026 19:10:13 +0300, Mehmet Koseoglu wrote:
> cpufreq_cpu_get() returns either a referenced policy or NULL.
> PolicyCpu::from_cpu() passed its return value to from_err_ptr(), which
> rejects ERR_PTR values but accepts NULL.
[...]
> Ok(Self(
> // SAFETY: The `ptr` is guaranteed to be valid and remains valid for the lifetime of
> // the returned reference.
> - unsafe { Policy::from_raw_mut(ptr) },
> + unsafe { Policy::from_raw_mut(ptr.as_ptr()) },
Just a quick nit here, maybe rephrase this SAFETY comment, e.g.:
// SAFETY: `ptr` is non-NULL and `cpufreq_cpu_get()` took a reference on it, so it is
// valid for writing and remains valid for the lifetime of the returned reference.
Either way, looks good to me.
FWIW, I hit this too and have a reproducer [1].
[1] https://github.com/Rust-for-Linux/linux/issues/1258
Reviewed-by: Elowen Xu <malanalyzing@gmail.com>
next prev parent reply other threads:[~2026-09-28 16:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-29 16:10 Mehmet Koseoglu
2026-08-29 19:52 ` Onur Özkan
2026-09-28 16:22 ` spidermana [this message]
2026-09-28 17:17 ` Miguel Ojeda
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=20260928162214.487564-1-xuyiwen14@gmail.com \
--to=xuyiwen14@gmail.com \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--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=linux-pm@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=mehmet.mkoseoglu@gmail.com \
--cc=ojeda@kernel.org \
--cc=rafael@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tamird@kernel.org \
--cc=tmgross@umich.edu \
--cc=viresh.kumar@linaro.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®