compat: fs: Generic compat_sys_sendfile implementation
[firefly-linux-kernel-4.4.55.git] / fs / eventpoll.c
index 1c8b55670804c20e88a10a48668f574d54f58205..cd96649bfe62da9e408dbd629f56f6452c139bc9 100644 (file)
@@ -1654,8 +1654,8 @@ SYSCALL_DEFINE1(epoll_create1, int, flags)
                error = PTR_ERR(file);
                goto out_free_fd;
        }
-       fd_install(fd, file);
        ep->file = file;
+       fd_install(fd, file);
        return fd;
 
 out_free_fd:
@@ -1810,7 +1810,7 @@ SYSCALL_DEFINE4(epoll_wait, int, epfd, struct epoll_event __user *, events,
                int, maxevents, int, timeout)
 {
        int error;
-       struct file *file;
+       struct fd f;
        struct eventpoll *ep;
 
        /* The maximum number of event must be greater than zero */
@@ -1818,38 +1818,33 @@ SYSCALL_DEFINE4(epoll_wait, int, epfd, struct epoll_event __user *, events,
                return -EINVAL;
 
        /* Verify that the area passed by the user is writeable */
-       if (!access_ok(VERIFY_WRITE, events, maxevents * sizeof(struct epoll_event))) {
-               error = -EFAULT;
-               goto error_return;
-       }
+       if (!access_ok(VERIFY_WRITE, events, maxevents * sizeof(struct epoll_event)))
+               return -EFAULT;
 
        /* Get the "struct file *" for the eventpoll file */
-       error = -EBADF;
-       file = fget(epfd);
-       if (!file)
-               goto error_return;
+       f = fdget(epfd);
+       if (!f.file)
+               return -EBADF;
 
        /*
         * We have to check that the file structure underneath the fd
         * the user passed to us _is_ an eventpoll file.
         */
        error = -EINVAL;
-       if (!is_file_epoll(file))
+       if (!is_file_epoll(f.file))
                goto error_fput;
 
        /*
         * At this point it is safe to assume that the "private_data" contains
         * our own data structure.
         */
-       ep = file->private_data;
+       ep = f.file->private_data;
 
        /* Time to fish for events ... */
        error = ep_poll(ep, events, maxevents, timeout);
 
 error_fput:
-       fput(file);
-error_return:
-
+       fdput(f);
        return error;
 }