From: Thorsten Blum <blum@kernel.org>
To: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Arve Hjønnevåg" <arve@android.com>,
"Todd Kjos" <tkjos@android.com>,
"Christian Brauner" <brauner@kernel.org>,
"Carlos Llamas" <cmllamas@google.com>,
"Alice Ryhl" <aliceryhl@google.com>,
"Nicolás Antinori" <nico.antinori.7@gmail.com>,
"Hyunwoo Kim" <imv4bel@gmail.com>,
"Sagar Taunk" <sagartaunk@proton.me>,
"Mohamad Alsadhan" <mo@sdhn.cc>,
"Sergey Gordeychik" <scadastrangelove@gmail.com>,
"Tamir Duberstein" <tamird@kernel.org>
Cc: Thorsten Blum <blum@kernel.org>, linux-kernel@vger.kernel.org
Subject: [PATCH] binder: replace unsafe NewAllocation transmute with field move
Date: Thu, 8 Oct 2026 11:29:05 +0200 [thread overview]
Message-ID: <20261008092906.179725-2-blum@kernel.org> (raw)
NewAllocation does not implement Drop and success() can return its
Allocation field directly. Also remove the now-unused transparent
representation.
Signed-off-by: Thorsten Blum <blum@kernel.org>
---
drivers/android/binder/allocation.rs | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/drivers/android/binder/allocation.rs b/drivers/android/binder/allocation.rs
index 165cb797eb1e..be405f2596ae 100644
--- a/drivers/android/binder/allocation.rs
+++ b/drivers/android/binder/allocation.rs
@@ -298,17 +298,13 @@ fn drop(&mut self) {
/// A wrapper around `Allocation` that is being created.
///
/// If the allocation is destroyed while wrapped in this wrapper, then the allocation will be
-/// considered to be part of a failed transaction. Successful transactions avoid that by calling
-/// `success`, which skips the destructor.
-#[repr(transparent)]
+/// considered to be part of a failed transaction. Successful transactions call `success` and
+/// store the returned `Allocation` in the new transaction.
pub(crate) struct NewAllocation(pub(crate) Allocation);
impl NewAllocation {
pub(crate) fn success(self) -> Allocation {
- // This skips the destructor.
- //
- // SAFETY: This type is `#[repr(transparent)]`, so the layout matches.
- unsafe { core::mem::transmute(self) }
+ self.0
}
}
reply other threads:[~2026-10-08 9:29 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261008092906.179725-2-blum@kernel.org \
--to=blum@kernel.org \
--cc=aliceryhl@google.com \
--cc=arve@android.com \
--cc=brauner@kernel.org \
--cc=cmllamas@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=imv4bel@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mo@sdhn.cc \
--cc=nico.antinori.7@gmail.com \
--cc=sagartaunk@proton.me \
--cc=scadastrangelove@gmail.com \
--cc=tamird@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®