aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-01-25 06:03:24 +1300
committerLinus Torvalds <torvalds@linux-foundation.org>2019-01-25 06:03:24 +1300
commitc04e2a780caf7073c31c4289c4b7c3d62f9c0130 (patch)
tree88bee60b3ae712768deeab2f3963a60bcfef9a8b /fs
parentMerge tag 'ceph-for-5.0-rc4' of git://github.com/ceph/ceph-client (diff)
parentinotify: Fix fd refcount leak in inotify_add_watch(). (diff)
downloadlinux-dev-c04e2a780caf7073c31c4289c4b7c3d62f9c0130.tar.xz
linux-dev-c04e2a780caf7073c31c4289c4b7c3d62f9c0130.zip
Merge tag 'fsnotify_for_v5.0-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs
Pull inotify fix from Jan Kara: "Fix a file refcount leak in an inotify error path" * tag 'fsnotify_for_v5.0-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs: inotify: Fix fd refcount leak in inotify_add_watch().
Diffstat (limited to 'fs')
-rw-r--r--fs/notify/inotify/inotify_user.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
index 105576daca4a..798f1253141a 100644
--- a/fs/notify/inotify/inotify_user.c
+++ b/fs/notify/inotify/inotify_user.c
@@ -724,8 +724,10 @@ SYSCALL_DEFINE3(inotify_add_watch, int, fd, const char __user *, pathname,
return -EBADF;
/* IN_MASK_ADD and IN_MASK_CREATE don't make sense together */
- if (unlikely((mask & IN_MASK_ADD) && (mask & IN_MASK_CREATE)))
- return -EINVAL;
+ if (unlikely((mask & IN_MASK_ADD) && (mask & IN_MASK_CREATE))) {
+ ret = -EINVAL;
+ goto fput_and_out;
+ }
/* verify that this is indeed an inotify instance */
if (unlikely(f.file->f_op != &inotify_fops)) {