aboutsummaryrefslogtreecommitdiffstats
path: root/fs/notify/inotify
diff options
context:
space:
mode:
Diffstat (limited to 'fs/notify/inotify')
-rw-r--r--fs/notify/inotify/inotify_user.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
index 5ef5f365a5c8..8271cf05c957 100644
--- a/fs/notify/inotify/inotify_user.c
+++ b/fs/notify/inotify/inotify_user.c
@@ -646,6 +646,7 @@ SYSCALL_DEFINE1(inotify_init1, int, flags)
646 struct fsnotify_group *group; 646 struct fsnotify_group *group;
647 struct user_struct *user; 647 struct user_struct *user;
648 struct file *filp; 648 struct file *filp;
649 struct path path;
649 int fd, ret; 650 int fd, ret;
650 651
651 /* Check the IN_* constants for consistency. */ 652 /* Check the IN_* constants for consistency. */
@@ -659,12 +660,6 @@ SYSCALL_DEFINE1(inotify_init1, int, flags)
659 if (fd < 0) 660 if (fd < 0)
660 return fd; 661 return fd;
661 662
662 filp = get_empty_filp();
663 if (!filp) {
664 ret = -ENFILE;
665 goto out_put_fd;
666 }
667
668 user = get_current_user(); 663 user = get_current_user();
669 if (unlikely(atomic_read(&user->inotify_devs) >= 664 if (unlikely(atomic_read(&user->inotify_devs) >=
670 inotify_max_user_instances)) { 665 inotify_max_user_instances)) {
@@ -679,24 +674,28 @@ SYSCALL_DEFINE1(inotify_init1, int, flags)
679 goto out_free_uid; 674 goto out_free_uid;
680 } 675 }
681 676
682 filp->f_op = &inotify_fops; 677 atomic_inc(&user->inotify_devs);
683 filp->f_path.mnt = mntget(inotify_mnt); 678
684 filp->f_path.dentry = dget(inotify_mnt->mnt_root); 679 path.mnt = inotify_mnt;
685 filp->f_mapping = filp->f_path.dentry->d_inode->i_mapping; 680 path.dentry = inotify_mnt->mnt_root;
686 filp->f_mode = FMODE_READ; 681 path_get(&path);
682 filp = alloc_file(&path, FMODE_READ, &inotify_fops);
683 if (!filp)
684 goto Enfile;
685
687 filp->f_flags = O_RDONLY | (flags & O_NONBLOCK); 686 filp->f_flags = O_RDONLY | (flags & O_NONBLOCK);
688 filp->private_data = group; 687 filp->private_data = group;
689 688
690 atomic_inc(&user->inotify_devs);
691
692 fd_install(fd, filp); 689 fd_install(fd, filp);
693 690
694 return fd; 691 return fd;
695 692
693Enfile:
694 ret = -ENFILE;
695 path_put(&path);
696 atomic_dec(&user->inotify_devs);
696out_free_uid: 697out_free_uid:
697 free_uid(user); 698 free_uid(user);
698 put_filp(filp);
699out_put_fd:
700 put_unused_fd(fd); 699 put_unused_fd(fd);
701 return ret; 700 return ret;
702} 701}