* [PATCH] binder: replace unsafe NewAllocation transmute with field move
@ 2026-10-08 9:29 Thorsten Blum
2026-10-13 9:15 ` Alice Ryhl
0 siblings, 1 reply; 2+ messages 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] 2+ messages in thread
* Re: [PATCH] binder: replace unsafe NewAllocation transmute with field move
2026-10-08 9:29 [PATCH] binder: replace unsafe NewAllocation transmute with field move Thorsten Blum
@ 2026-10-13 9:15 ` Alice Ryhl
0 siblings, 0 replies; 2+ messages in thread
From: Alice Ryhl @ 2026-10-13 9:15 UTC (permalink / raw)
To: Thorsten Blum
Cc: Greg Kroah-Hartman, Arve Hjønnevåg, Todd Kjos,
Christian Brauner, Carlos Llamas, Nicolás Antinori,
Hyunwoo Kim, Sagar Taunk, Mohamad Alsadhan, Sergey Gordeychik,
Tamir Duberstein, linux-kernel
On Thu, Oct 08, 2026 at 11:29:05AM +0200, Thorsten Blum wrote:
> 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>
The NewAllocation type implements Drop as of commit e2e4a4527d18
("rust_binder: allocation: call trace_transaction_failed_buffer_release()").
See: https://patch.msgid.link/20260927125622.676342-3-sagartaunk@proton.me
Alice
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-13 9:15 UTC | newest]
Thread overview: 2+ messages (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
2026-10-13 9:15 ` Alice Ryhl
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®