Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 26379198 authored by Eric Paris's avatar Eric Paris
Browse files

fanotify: do not leak user reference on allocation failure



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: default avatarVegard Nossum <vegard.nossum@gmail.com>
Signed-off-by: default avatarEric Paris <eparis@redhat.com>
parent a2ae4cc9
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -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);