Skip to content

Commit

Permalink
fanotify: do not leak user reference on allocation failure
Browse files Browse the repository at this point in the history
If fanotify_init is unable to allocate a new fsnotify group it will
return but will not drop its reference on the associated user struct.
Drop that reference on error.

Reported-by: Vegard Nossum <vegard.nossum@gmail.com>
Signed-off-by: Eric Paris <eparis@redhat.com>
  • Loading branch information
Eric Paris committed Dec 7, 2010
1 parent a2ae4cc commit 2637919
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion fs/notify/fanotify/fanotify_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -692,8 +692,10 @@ SYSCALL_DEFINE2(fanotify_init, unsigned int, flags, unsigned int, event_f_flags)

/* fsnotify_alloc_group takes a ref. Dropped in fanotify_release */
group = fsnotify_alloc_group(&fanotify_fsnotify_ops);
if (IS_ERR(group))
if (IS_ERR(group)) {
free_uid(user);
return PTR_ERR(group);
}

group->fanotify_data.user = user;
atomic_inc(&user->fanotify_listeners);
Expand Down

0 comments on commit 2637919

Please sign in to comment.