[PATCH] rust_binder: retry ready threads or fallback to proc queue on dead thread

From: Adhyansh Verma

Date: Fri Nov 27 2026 - 05:22:49 EST


When ProcessInner::push_work() attempts to deliver work to a waiting
thread from ready_threads, it previously checked only the first thread
with an 'if let'. If that thread has exited while waiting in the pool,
thread.push_work_inner() returns PushWorkRes::FailedDead(work).

Matching on FailedDead immediately returned Err(BinderError::new_dead()),
aborting the delivery and dropping the work item. This incorrectly
treated the entire process as dead, even though the process itself was
alive, other live worker threads might be available in ready_threads,
and the process work queue (self.work) was ready to accept the work.

Change the lookup to a 'while let' loop so that if a popped thread is
dead, push_work() continues checking any remaining ready threads. If no
ready threads remain, fall back to queuing the work on self.work, only
returning an error if self.is_dead is actually true.

Fixes: eafedbc7c050 ("rust_binder: add Rust Binder driver")
Cc: stable@xxxxxxxxxxxxxxx
---
drivers/android/binder/process.rs | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/android/binder/process.rs b/drivers/android/binder/process.rs
index 1f4cb43f1de..b7b53b99689 100644
--- a/drivers/android/binder/process.rs
+++ b/drivers/android/binder/process.rs
@@ -184,23 +184,27 @@ fn new() -> Self {
pub(crate) fn push_work(
&mut self,
proc: &Process,
- work: DLArc<dyn DeliverToRead>,
+ mut work: DLArc<dyn DeliverToRead>,
) -> Result<(), (BinderError, DLArc<dyn DeliverToRead>)> {
let sync = work.should_sync_wakeup();

// Try to find a ready thread to which to push the work.
- if let Some(thread) = self.ready_threads.pop_front() {
+ while let Some(thread) = self.ready_threads.pop_front() {
// Push to thread while holding state lock. This prevents the thread from giving up
// (for example, because of a signal) when we're about to deliver work.
match thread.push_work_inner(work, sync) {
- PushWorkRes::Ok => Ok(()),
+ PushWorkRes::Ok => return Ok(()),
PushWorkRes::OkNotifyPoll => {
proc.notify_poll(sync);
- Ok(())
+ return Ok(());
+ }
+ PushWorkRes::FailedDead(dead_work) => {
+ work = dead_work;
}
- PushWorkRes::FailedDead(work) => Err((BinderError::new_dead(), work)),
}
- } else if self.is_dead {
+ }
+
+ if self.is_dead {
Err((BinderError::new_dead(), work))
} else {
// Didn't find a thread waiting for proc work; this can happen
--
2.56.1