Replace copy-pasted `fget_from_files' -> `filp_close' with
a `sys_close' call.

Signed-off-by: Pavel Boldin <pboldin at mirantis.com>
---
 lib/librte_vhost/eventfd_link/eventfd_link.c | 49 +++++++---------------------
 1 file changed, 12 insertions(+), 37 deletions(-)

diff --git a/lib/librte_vhost/eventfd_link/eventfd_link.c 
b/lib/librte_vhost/eventfd_link/eventfd_link.c
index 0a06594..9bc52a3 100644
--- a/lib/librte_vhost/eventfd_link/eventfd_link.c
+++ b/lib/librte_vhost/eventfd_link/eventfd_link.c
@@ -88,9 +88,8 @@ eventfd_link_ioctl_copy(unsigned long arg)
 {
        void __user *argp = (void __user *) arg;
        struct task_struct *task_target = NULL;
-       struct file *file;
-       struct files_struct *files;
-       struct fdtable *fdt;
+       struct file *target_file;
+       struct files_struct *target_files;
        struct eventfd_copy eventfd_copy;
        long ret = -EFAULT;

@@ -109,51 +108,27 @@ eventfd_link_ioctl_copy(unsigned long arg)
                goto out;
        }

-       ret = -ESTALE;
-       files = get_files_struct(current);
-       if (files == NULL) {
-               pr_info("Failed to get current files struct\n");
-               goto out_task;
-       }
-
-       ret = -EBADF;
-       file = fget_from_files(files, eventfd_copy.source_fd);
-
-       if (file == NULL) {
-               pr_info("Failed to get fd %d from source\n",
-                       eventfd_copy.source_fd);
-               put_files_struct(files);
+       /* Closing the source_fd */
+       ret = sys_close(eventfd_copy.source_fd);
+       if (ret)
                goto out_task;
-       }
-
-       /*
-        * Release the existing eventfd in the source process
-        */
-       spin_lock(&files->file_lock);
-       fput(file);
-       filp_close(file, files);
-       fdt = files_fdtable(files);
-       fdt->fd[eventfd_copy.source_fd] = NULL;
-       spin_unlock(&files->file_lock);
-
-       put_files_struct(files);
+       ret = -ESTALE;

        /*
         * Find the file struct associated with the target fd.
         */

-       ret = -ESTALE;
-       files = get_files_struct(task_target);
-       if (files == NULL) {
+       target_files = get_files_struct(task_target);
+       if (target_files == NULL) {
                pr_info("Failed to get target files struct\n");
                goto out_task;
        }

        ret = -EBADF;
-       file = fget_from_files(files, eventfd_copy.target_fd);
-       put_files_struct(files);
+       target_file = fget_from_files(target_files, eventfd_copy.target_fd);
+       put_files_struct(target_files);

-       if (file == NULL) {
+       if (target_file == NULL) {
                pr_info("Failed to get fd %d from target\n",
                        eventfd_copy.target_fd);
                goto out_task;
@@ -164,7 +139,7 @@ eventfd_link_ioctl_copy(unsigned long arg)
         * file desciptor of the source process,
         */

-       fd_install(eventfd_copy.source_fd, file);
+       fd_install(eventfd_copy.source_fd, target_file);
        ret = 0;

 out_task:
-- 
1.9.1

Reply via email to