From: Alice Ryhl <aliceryhl@google.com>
To: Adhyansh Verma <adhyanshverma2010@gmail.com>
Cc: "Alice Ryhl" <aliceryhl@google.com>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Carlos Llamas" <cmllamas@google.com>,
"Arve Hjønnevåg" <arve@android.com>,
"Todd Kjos" <tkjos@android.com>,
"Christian Brauner" <brauner@kernel.org>,
"Miguel Ojeda" <ojeda@kernel.org>,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] rust_binder: return ENOMEM on shrinker allocation failure
Date: Sun, 29 Nov 2026 11:16:52 +0000 [thread overview]
Message-ID: <20261129111652.1264306-1-aliceryhl@google.com> (raw)
In-Reply-To: <20261128153529.143070-1-adhyanshverma2010@gmail.com>
On Sat, Nov 28, 2026 at 09:05:29PM +0530, Adhyansh Verma wrote:
> In Shrinker::register(), __list_lru_init() is called to initialize the
> list_lru. When it succeeds, ret is 0. Subsequently, shrinker_alloc() is
> called to allocate the shrinker. If memory allocation fails, shrinker is
> null and the error cleanup path executes:
>
> unsafe { bindings::list_lru_destroy(self.list_lru.get()) };
> return Err(Error::from_errno(ret));
>
> Because ret is still 0 from the earlier successful __list_lru_init(),
> Error::from_errno(0) is called.
>
> Per rust/kernel/error.rs, passing 0 to Error::from_errno() is considered
> a kernel bug. It triggers a pr_warn! warning ("attempted to create Error
> with out of range errno: 0") and falls back to EINVAL instead of
> returning ENOMEM to indicate the allocation failure.
>
> Fix this by returning Err(ENOMEM) directly when shrinker_alloc() returns
> null.
>
> Fixes: eafedbc7c050 ("rust_binder: add Rust Binder driver")
> Signed-off-by: Adhyansh Verma <adhyanshverma2010@gmail.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Alice
next prev parent reply other threads:[~2026-11-29 11:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-28 15:35 Adhyansh Verma
2026-11-29 11:16 ` Alice Ryhl [this message]
[not found] <20261128153529.144983-1-adhyanshverma2010@gmail.com>
2026-11-29 12:15 ` Adhyansh Verma
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=20261129111652.1264306-1-aliceryhl@google.com \
--to=aliceryhl@google.com \
--cc=adhyanshverma2010@gmail.com \
--cc=arve@android.com \
--cc=brauner@kernel.org \
--cc=cmllamas@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tkjos@android.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
all inboxes | Powered by JetHome®