Commit 5eb22cbc authored by Robert Love's avatar Robert Love Committed by Linus Torvalds

[PATCH] inotify: exit path cleanups

Handle error out paths better.
Signed-off-by: default avatarRobert Love <rml@novell.com>
Signed-off-by: default avatarJohn McCutchan <ttb@tentacle.dhs.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 783bc29b
...@@ -865,23 +865,21 @@ asmlinkage long sys_inotify_init(void) ...@@ -865,23 +865,21 @@ asmlinkage long sys_inotify_init(void)
filp = get_empty_filp(); filp = get_empty_filp();
if (!filp) { if (!filp) {
put_unused_fd(fd);
ret = -ENFILE; ret = -ENFILE;
goto out; goto out_put_fd;
} }
user = get_uid(current->user); user = get_uid(current->user);
if (unlikely(atomic_read(&user->inotify_devs) >= if (unlikely(atomic_read(&user->inotify_devs) >=
inotify_max_user_instances)) { inotify_max_user_instances)) {
ret = -EMFILE; ret = -EMFILE;
goto out_err; goto out_free_uid;
} }
dev = kmalloc(sizeof(struct inotify_device), GFP_KERNEL); dev = kmalloc(sizeof(struct inotify_device), GFP_KERNEL);
if (unlikely(!dev)) { if (unlikely(!dev)) {
ret = -ENOMEM; ret = -ENOMEM;
goto out_err; goto out_free_uid;
} }
filp->f_op = &inotify_fops; filp->f_op = &inotify_fops;
...@@ -908,11 +906,11 @@ asmlinkage long sys_inotify_init(void) ...@@ -908,11 +906,11 @@ asmlinkage long sys_inotify_init(void)
fd_install(fd, filp); fd_install(fd, filp);
return fd; return fd;
out_err: out_free_uid:
put_unused_fd (fd);
put_filp (filp);
free_uid(user); free_uid(user);
out: put_filp(filp);
out_put_fd:
put_unused_fd(fd);
return ret; return ret;
} }
...@@ -975,9 +973,9 @@ asmlinkage long sys_inotify_add_watch(int fd, const char __user *path, u32 mask) ...@@ -975,9 +973,9 @@ asmlinkage long sys_inotify_add_watch(int fd, const char __user *path, u32 mask)
list_add(&watch->i_list, &inode->inotify_watches); list_add(&watch->i_list, &inode->inotify_watches);
ret = watch->wd; ret = watch->wd;
out: out:
path_release (&nd);
up(&dev->sem); up(&dev->sem);
up(&inode->inotify_sem); up(&inode->inotify_sem);
path_release(&nd);
fput_and_out: fput_and_out:
fput_light(filp, fput_needed); fput_light(filp, fput_needed);
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment