From cb9a5a6a200e8904beebc099ef8b2351fa9fbb42 Mon Sep 17 00:00:00 2001 From: Andy Ross Date: Thu, 28 Mar 2013 11:29:41 -0700 Subject: [PATCH] binder: handle syscall restart in BINDER_WRITE_READ ioctl The blocking wait in the "read" half of the ioctl could wake up on signal delivery, and the default ERESTARTSYS handling would cause the whole syscall to restart resulting in a doubled write. Issue: AXIA-1880 Change-Id: Id49e4a088d08feca63bff43d28be6530820d9c3d Signed-off-by: Andy Ross --- drivers/staging/android/binder.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/staging/android/binder.c b/drivers/staging/android/binder.c index c69c40d69d5c..0782fc927829 100644 --- a/drivers/staging/android/binder.c +++ b/drivers/staging/android/binder.c @@ -2190,8 +2190,13 @@ retry: proc->ready_threads--; thread->looper &= ~BINDER_LOOPER_STATE_WAITING; + /* We cannot return -ERESTARTSYS here. This code is called + * after binder_thread_write() has already interpreted the + * input buffer. A restart will result in a doubled set of + * commands. Just return success, having consumed zero + * bytes. */ if (ret) - return ret; + return ret == -ERESTARTSYS ? 0 : ret; while (1) { uint32_t cmd; -- 2.11.0