Skip to content
Snippets Groups Projects
Commit fd8b0100 authored by Greg Hackmann's avatar Greg Hackmann Committed by Lingfeng Yang
Browse files

ANDROID: goldfish: goldfish_pipe: fix locking errors


NOTE: This is a cherry-pick of the kernel/common/android-4.4 patch
      37e461fc into the kernel/goldfish/android-goldfish-3.10 branch.

If the get_user_pages_fast() call in goldfish_pipe_read_write() failed,
it would return while still holding pipe->lock.

goldfish_pipe_read_write() later releases and tries to re-acquire
pipe->lock.  If the re-acquire call failed, goldfish_pipe_read_write()
would try unlock pipe->lock on exit anyway.

This fixes the smatch messages:

drivers/platform/goldfish/goldfish_pipe.c:392 goldfish_pipe_read_write() error: double unlock 'mutex:&pipe->lock'
drivers/platform/goldfish/goldfish_pipe.c:397 goldfish_pipe_read_write() warn: inconsistent returns 'mutex:&pipe->lock'.

Change-Id: Id60afd6c191f69af86386405d397b6ad2dd37079
Signed-off-by: default avatarGreg Hackmann <ghackmann@google.com>
parent 5fff79b1
No related branches found
No related tags found
No related merge requests found
......@@ -279,11 +279,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;
}
......@@ -395,10 +397,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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment