From: Timur Tabi <ttabi@nvidia.com>
To: John Hubbard <jhubbard@nvidia.com>,
"alvin.sun@linux.dev" <alvin.sun@linux.dev>,
Eliot Courtney <ecourtney@nvidia.com>,
"nova-gpu@lists.linux.dev" <nova-gpu@lists.linux.dev>,
"rust-for-linux@vger.kernel.org" <rust-for-linux@vger.kernel.org>,
Zhi Wang <zhiw@nvidia.com>,
"mcgrof@kernel.org" <mcgrof@kernel.org>,
"dakr@kernel.org" <dakr@kernel.org>,
"gary@garyguo.net" <gary@garyguo.net>,
"russ.weight@linux.dev" <russ.weight@linux.dev>,
"driver-core@lists.linux.dev" <driver-core@lists.linux.dev>,
Alexandre Courbot <acourbot@nvidia.com>,
"ojeda@kernel.org" <ojeda@kernel.org>
Subject: Re: [PATCH v3 1/7] rust: firmware: add request_into_buf()
Date: Fri, 3 Jul 2026 03:06:51 +0000 [thread overview]
Message-ID: <5515b3a5d405dba4d04c628b435065b5e3b631bc.camel@nvidia.com> (raw)
In-Reply-To: <a87b3b29-3dcf-425c-b700-da957400daea@linux.dev>
On Fri, 2026-07-03 at 10:51 +0800, Alvin Sun wrote:
> > +pub fn request_into_buf(name: &CStr, dev: &Device, buf: &mut [u8]) -> Result {
> > + // `as_mut_ptr()` on an empty slice returns a non-NULL pointer to
> > + // memory which the loader does not own. Passing that pointer with `size == 0`
> > + // makes the loader believe that it is buffer it allocated itself, so when
> > + // `release_firmware()` is called, it will vfree the pointer and trigger a
> > + // bug. Reject empty slices to avoid this situation.
> > + if buf.is_empty() {
> > + return Err(crate::error::code::EINVAL);
>
> `EINVAL` is already in prelude, you can use it directly.
I would have to add it to the list of imports.
> > + // SAFETY: `pfw` is a valid pointer to a NULL initialized `bindings::firmware` pointer.
> > + // `name` and `dev` are valid as by their type invariants. `buf` is a valid writable
> > + // buffer of `buf.len()` bytes.
> > + let ret = unsafe {
> > + bindings::request_firmware_into_buf(
> > + pfw,
> > + name.as_char_ptr(),
> > + dev.as_raw(),
> > + buf.as_mut_ptr().cast(),
> > + buf.len(),
> > + )
> > + };
> > + if ret != 0 {
> > + return Err(Error::from_errno(ret));
> > + }
>
> `to_result` can be used here to simplify.
Will add in v4.
next prev parent reply other threads:[~2026-07-03 3:07 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-02 19:27 [PATCH v3 0/7] Transition Nova Core to TLV firmare images Timur Tabi
2026-07-02 19:27 ` [PATCH v3 1/7] rust: firmware: add request_into_buf() Timur Tabi
2026-07-03 2:51 ` Alvin Sun
2026-07-03 3:06 ` Timur Tabi [this message]
2026-07-03 13:51 ` Danilo Krummrich
2026-07-06 6:30 ` Alexandre Courbot
2026-07-06 10:50 ` Danilo Krummrich
2026-07-07 2:54 ` Timur Tabi
2026-07-07 5:10 ` Alexandre Courbot
2026-07-07 13:32 ` Danilo Krummrich
2026-07-02 19:27 ` [PATCH v3 2/7] gpu: nova-core: add TLV parser for firmware files Timur Tabi
2026-07-02 19:45 ` Timur Tabi
2026-07-06 6:31 ` Alexandre Courbot
2026-07-07 2:56 ` Timur Tabi
2026-07-07 5:13 ` Alexandre Courbot
2026-07-06 6:31 ` Alexandre Courbot
2026-07-02 19:27 ` [PATCH v3 3/7] gpu: nova-core: transition booter_load to TLV images Timur Tabi
2026-07-06 6:31 ` Alexandre Courbot
2026-07-02 19:27 ` [PATCH v3 4/7] gpu: nova-core: transition gsp " Timur Tabi
2026-07-02 19:27 ` [PATCH v3 5/7] gpu: nova-core: transition gen_bootloader " Timur Tabi
2026-07-06 6:31 ` Alexandre Courbot
2026-07-02 19:27 ` [PATCH v3 6/7] gpu: nova-core: transition fsp " Timur Tabi
2026-07-02 19:27 ` [PATCH v3 7/7] gpu: nova-core: update firmware module info for " Timur Tabi
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=5515b3a5d405dba4d04c628b435065b5e3b631bc.camel@nvidia.com \
--to=ttabi@nvidia.com \
--cc=acourbot@nvidia.com \
--cc=alvin.sun@linux.dev \
--cc=dakr@kernel.org \
--cc=driver-core@lists.linux.dev \
--cc=ecourtney@nvidia.com \
--cc=gary@garyguo.net \
--cc=jhubbard@nvidia.com \
--cc=mcgrof@kernel.org \
--cc=nova-gpu@lists.linux.dev \
--cc=ojeda@kernel.org \
--cc=russ.weight@linux.dev \
--cc=rust-for-linux@vger.kernel.org \
--cc=zhiw@nvidia.com \
/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