diff options
author | Rebecca Schultz Zavin <rebecca@android.com> | 2013-03-01 00:43:12 (GMT) |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-03-04 09:44:08 (GMT) |
commit | 92ea915adb5565b522902a7b3f0a33ede16bb797 (patch) | |
tree | f7d404165bff7e33a25772fb5ade522c1a225dde /drivers/staging/android/sync.c | |
parent | c5b86b7418f46220a623277718d6a909f520477b (diff) | |
download | linux-fsl-qoriq-92ea915adb5565b522902a7b3f0a33ede16bb797.tar.xz |
staging: 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.
Cc: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Cc: Erik Gilling <konkers@android.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Rob Clark <robclark@gmail.com>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: dri-devel@lists.freedesktop.org
Cc: Android Kernel Team <kernel-team@android.com>
Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/android/sync.c')
-rw-r--r-- | drivers/staging/android/sync.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c index 61c27bd..c4a3c1d 100644 --- a/drivers/staging/android/sync.c +++ b/drivers/staging/android/sync.c @@ -647,8 +647,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) { |