diff options
| -rw-r--r-- | fs/inotify.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/fs/inotify.c b/fs/inotify.c index b55d6e4a0911..d41c53c8dfd0 100644 --- a/fs/inotify.c +++ b/fs/inotify.c | |||
| @@ -865,23 +865,21 @@ asmlinkage long sys_inotify_init(void) | |||
| 865 | 865 | ||
| 866 | filp = get_empty_filp(); | 866 | filp = get_empty_filp(); |
| 867 | if (!filp) { | 867 | if (!filp) { |
| 868 | put_unused_fd(fd); | ||
| 869 | ret = -ENFILE; | 868 | ret = -ENFILE; |
| 870 | goto out; | 869 | goto out_put_fd; |
| 871 | } | 870 | } |
| 872 | 871 | ||
| 873 | user = get_uid(current->user); | 872 | user = get_uid(current->user); |
| 874 | |||
| 875 | if (unlikely(atomic_read(&user->inotify_devs) >= | 873 | if (unlikely(atomic_read(&user->inotify_devs) >= |
| 876 | inotify_max_user_instances)) { | 874 | inotify_max_user_instances)) { |
| 877 | ret = -EMFILE; | 875 | ret = -EMFILE; |
| 878 | goto out_err; | 876 | goto out_free_uid; |
| 879 | } | 877 | } |
| 880 | 878 | ||
| 881 | dev = kmalloc(sizeof(struct inotify_device), GFP_KERNEL); | 879 | dev = kmalloc(sizeof(struct inotify_device), GFP_KERNEL); |
| 882 | if (unlikely(!dev)) { | 880 | if (unlikely(!dev)) { |
| 883 | ret = -ENOMEM; | 881 | ret = -ENOMEM; |
| 884 | goto out_err; | 882 | goto out_free_uid; |
| 885 | } | 883 | } |
| 886 | 884 | ||
| 887 | filp->f_op = &inotify_fops; | 885 | filp->f_op = &inotify_fops; |
| @@ -908,11 +906,11 @@ asmlinkage long sys_inotify_init(void) | |||
| 908 | fd_install(fd, filp); | 906 | fd_install(fd, filp); |
| 909 | 907 | ||
| 910 | return fd; | 908 | return fd; |
| 911 | out_err: | 909 | out_free_uid: |
| 912 | put_unused_fd (fd); | ||
| 913 | put_filp (filp); | ||
| 914 | free_uid(user); | 910 | free_uid(user); |
| 915 | out: | 911 | put_filp(filp); |
| 912 | out_put_fd: | ||
| 913 | put_unused_fd(fd); | ||
| 916 | return ret; | 914 | return ret; |
| 917 | } | 915 | } |
| 918 | 916 | ||
| @@ -975,9 +973,9 @@ asmlinkage long sys_inotify_add_watch(int fd, const char __user *path, u32 mask) | |||
| 975 | list_add(&watch->i_list, &inode->inotify_watches); | 973 | list_add(&watch->i_list, &inode->inotify_watches); |
| 976 | ret = watch->wd; | 974 | ret = watch->wd; |
| 977 | out: | 975 | out: |
| 978 | path_release (&nd); | ||
| 979 | up(&dev->sem); | 976 | up(&dev->sem); |
| 980 | up(&inode->inotify_sem); | 977 | up(&inode->inotify_sem); |
| 978 | path_release(&nd); | ||
| 981 | fput_and_out: | 979 | fput_and_out: |
| 982 | fput_light(filp, fput_needed); | 980 | fput_light(filp, fput_needed); |
| 983 | return ret; | 981 | return ret; |
