From: Rebecca Schultz Zavin Date: Wed, 8 Aug 2012 20:46:22 +0000 (-0700) Subject: sync: Fix error paths X-Git-Tag: firefly_0821_release~7564 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=8c83534550ca7904cffa0de2d47562e447e051fb;p=firefly-linux-kernel-4.4.55.git 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 --- diff --git a/drivers/base/sync.c b/drivers/base/sync.c index 74d06491cd4a..d12efbf0d24e 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) {