diff options
author | Rebecca Schultz Zavin <rebecca@android.com> | 2012-08-08 13:46:22 -0700 |
---|---|---|
committer | Varun Wadekar <vwadekar@nvidia.com> | 2012-08-13 14:13:19 +0530 |
commit | 9b4436ab334a870acf102bad5eb0155c7823a34e (patch) | |
tree | 8e452dce7ab78212b82426047f76d1d85ae39676 | |
parent | e274e91ec5cb58174c672674df400626a11a3600 (diff) |
sync: Fix error paths
Check the return value of get_unused_fd to make sure a valid
file descriptor is returned.
Make sure to call put_unused_fd even if an error occurs before
the fd can be used.
Change-Id: I0fe8f78d9e30ecfc4d271c5d875424543dae2d0f
Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>
-rw-r--r-- | drivers/base/sync.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/base/sync.c b/drivers/base/sync.c index ad3fee0bcbeb..eee2e56cdaf5 100644 --- a/drivers/base/sync.c +++ b/drivers/base/sync.c @@ -650,8 +650,13 @@ static long sync_fence_ioctl_merge(struct sync_fence *fence, unsigned long arg) struct sync_fence *fence2, *fence3; struct sync_merge_data data; - if (copy_from_user(&data, (void __user *)arg, sizeof(data))) - return -EFAULT; + if (fd < 0) + return fd; + + if (copy_from_user(&data, (void __user *)arg, sizeof(data))) { + err = -EFAULT; + goto err_put_fd; + } fence2 = sync_fence_fdget(data.fd2); if (fence2 == NULL) { |