Skip to content

Commit

Permalink
[PATCH] inotify: exit path cleanups
Browse files Browse the repository at this point in the history
Handle error out paths better.

Signed-off-by: Robert Love <[email protected]>
Signed-off-by: John McCutchan <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Robert Love authored and Linus Torvalds committed Jul 26, 2005
1 parent 783bc29 commit 5eb22cb
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions fs/inotify.c
Original file line number Diff line number Diff line change
Expand Up @@ -865,23 +865,21 @@ asmlinkage long sys_inotify_init(void)

filp = get_empty_filp();
if (!filp) {
put_unused_fd(fd);
ret = -ENFILE;
goto out;
goto out_put_fd;
}

user = get_uid(current->user);

if (unlikely(atomic_read(&user->inotify_devs) >=
inotify_max_user_instances)) {
ret = -EMFILE;
goto out_err;
goto out_free_uid;
}

dev = kmalloc(sizeof(struct inotify_device), GFP_KERNEL);
if (unlikely(!dev)) {
ret = -ENOMEM;
goto out_err;
goto out_free_uid;
}

filp->f_op = &inotify_fops;
Expand All @@ -908,11 +906,11 @@ asmlinkage long sys_inotify_init(void)
fd_install(fd, filp);

return fd;
out_err:
put_unused_fd (fd);
put_filp (filp);
out_free_uid:
free_uid(user);
out:
put_filp(filp);
out_put_fd:
put_unused_fd(fd);
return ret;
}

Expand Down Expand Up @@ -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);
ret = watch->wd;
out:
path_release (&nd);
up(&dev->sem);
up(&inode->inotify_sem);
path_release(&nd);
fput_and_out:
fput_light(filp, fput_needed);
return ret;
Expand Down

0 comments on commit 5eb22cb

Please sign in to comment.