ANDROID: goldfish: goldfish_pipe: fix locking errors
[firefly-linux-kernel-4.4.55.git] / drivers / platform / goldfish / goldfish_pipe.c
index cf7ce97e7346ed9306187ad36cdee36c695253db..fd1452e283522d0e79943e9fa85db57351a32221 100644 (file)
@@ -273,11 +273,13 @@ static ssize_t goldfish_pipe_read_write(struct file *filp, char __user *buffer,
                if (ret == 0) {
                        DPRINT("%s: error: (requested pages == 0) (wanted %d)\n",
                                        __FUNCTION__, requested_pages);
+                       mutex_unlock(&pipe->lock);
                        return ret;
                }
                if (ret < 0) {
                        DPRINT("%s: (requested pages < 0) %d \n",
                                        __FUNCTION__, requested_pages);
+                       mutex_unlock(&pipe->lock);
                        return ret;
                }
 
@@ -384,10 +386,8 @@ static ssize_t goldfish_pipe_read_write(struct file *filp, char __user *buffer,
                }
 
                /* Try to re-acquire the lock */
-               if (mutex_lock_interruptible(&pipe->lock)) {
-                       ret = -ERESTARTSYS;
-                       break;
-               }
+               if (mutex_lock_interruptible(&pipe->lock))
+                       return -ERESTARTSYS;
        }
        mutex_unlock(&pipe->lock);