mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] binder: replace unsafe NewAllocation transmute with field move
@ 2026-10-08  9:29 Thorsten Blum
  0 siblings, 0 replies; only message in thread
From: Thorsten Blum @ 2026-10-08  9:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Arve Hjønnevåg, Todd Kjos,
	Christian Brauner, Carlos Llamas, Alice Ryhl,
	Nicolás Antinori, Hyunwoo Kim, Sagar Taunk,
	Mohamad Alsadhan, Sergey Gordeychik, Tamir Duberstein
  Cc: Thorsten Blum, linux-kernel

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
     }
 }
 

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-10-08  9:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-08  9:29 [PATCH] binder: replace unsafe NewAllocation transmute with field move Thorsten Blum

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®