inotify: Fix fd refcount leak in inotify_add_watch().

Commit 4d97f7d53d ("inotify: Add flag IN_MASK_CREATE for
inotify_add_watch()") forgot to call fdput() before bailing out.

Fixes: 4d97f7d53d ("inotify: Add flag IN_MASK_CREATE for inotify_add_watch()")
CC: stable@vger.kernel.org
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
This commit is contained in:
Tetsuo Handa 2019-01-01 18:54:26 +09:00 committed by Jan Kara
parent 8e143b90e4
commit 125892edfe

View File

@ -724,8 +724,10 @@ SYSCALL_DEFINE3(inotify_add_watch, int, fd, const char __user *, pathname,
return -EBADF; return -EBADF;
/* IN_MASK_ADD and IN_MASK_CREATE don't make sense together */ /* IN_MASK_ADD and IN_MASK_CREATE don't make sense together */
if (unlikely((mask & IN_MASK_ADD) && (mask & IN_MASK_CREATE))) if (unlikely((mask & IN_MASK_ADD) && (mask & IN_MASK_CREATE))) {
return -EINVAL; ret = -EINVAL;
goto fput_and_out;
}
/* verify that this is indeed an inotify instance */ /* verify that this is indeed an inotify instance */
if (unlikely(f.file->f_op != &inotify_fops)) { if (unlikely(f.file->f_op != &inotify_fops)) {