aboutsummaryrefslogtreecommitdiffstats
path: root/fs/inotify.c
diff options
context:
space:
mode:
authorRobert Love <rml@novell.com>2005-07-25 15:12:19 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-07-26 16:37:22 -0400
commit5eb22cbcdb849886c2584389faff5afb56c23876 (patch)
tree4a0147ea3f2021091c0ce686dc10225ef0ac7d83 /fs/inotify.c
parent783bc29bbc5d6625a4669d3eb1d989a8fb275d43 (diff)
[PATCH] inotify: exit path cleanups
Handle error out paths better. Signed-off-by: Robert Love <rml@novell.com> Signed-off-by: John McCutchan <ttb@tentacle.dhs.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/inotify.c')
-rw-r--r--fs/inotify.c18
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;
911out_err: 909out_free_uid:
912 put_unused_fd (fd);
913 put_filp (filp);
914 free_uid(user); 910 free_uid(user);
915out: 911 put_filp(filp);
912out_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;
977out: 975out:
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);
981fput_and_out: 979fput_and_out:
982 fput_light(filp, fput_needed); 980 fput_light(filp, fput_needed);
983 return ret; 981 return ret;