OSDN Git Service

binder: handle syscall restart in BINDER_WRITE_READ ioctl
authorAndy Ross <andy.ross@windriver.com>
Thu, 28 Mar 2013 18:29:41 +0000 (11:29 -0700)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Sat, 13 Dec 2014 17:04:42 +0000 (01:04 +0800)
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 <andy.ross@windriver.com>
drivers/staging/android/binder.c

index c69c40d..0782fc9 100644 (file)
@@ -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;