diff options
| author | Alice Ryhl <aliceryhl@google.com> | 2026-09-30 13:56:36 +0000 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2026-10-01 14:34:04 +0200 |
| commit | 32d0ed324f6fc9428f2942c48ea5d2530e08665a (patch) | |
| tree | 0c78f6ca42caf37f76da653019ebf2a1ae3b8781 /drivers/android/binder | |
| parent | d835f4b1add32d6cf125114e1f7a51931b290ccd (diff) | |
rust_binder: never return 0 from next_debug_id
Retry if fetch_add returns 0 in next_debug_id() so that valid debug IDs
start at 1 and 0 is never assigned, even if NEXT_DEBUG_ID wraps around.
This allows 0 to be used as a sentinel for an absent or uninitialized
debug_id (such as in TransactionInfo::to_node_debug_id and in
transaction log entries).
Assisted-by: LLM
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
Link: https://patch.msgid.link/20260930-binder-transaction-log-v2-1-8a15e9b8cae3@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/android/binder')
| -rw-r--r-- | drivers/android/binder/rust_binder_main.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/android/binder/rust_binder_main.rs b/drivers/android/binder/rust_binder_main.rs index 92bf33f9ff1c..89add66c0483 100644 --- a/drivers/android/binder/rust_binder_main.rs +++ b/drivers/android/binder/rust_binder_main.rs @@ -98,7 +98,12 @@ static RUST_BINDER_LAYOUT: rust_binder_layout = rust_binder_layout { fn next_debug_id() -> usize { static NEXT_DEBUG_ID: Atomic<usize> = Atomic::new(0); - NEXT_DEBUG_ID.fetch_add(1, Relaxed) + loop { + let id = NEXT_DEBUG_ID.fetch_add(1, Relaxed); + if id != 0 { + return id; + } + } } /// Provides a single place to write Binder return values via the |
