From 23717b34e39a02a32960d8f0bae73fc3b552968c Mon Sep 17 00:00:00 2001 From: ZhangXiaoxu Date: Tue, 5 Mar 2019 10:21:45 +0800 Subject: [PATCH] inotify: Fix fsnotify_mark refcount leak in inotify_update_existing_watch() euler inclusion category: bugfix bugzilla: 10982 CVE: NA -------------------------------------------------- commit 4d97f7d53da7dc83 ("inotify: Add flag IN_MASK_CREATE for inotify_add_watch()") forgot to call fsnotify_put_mark() with IN_MASK_CREATE after fsnotify_find_mark() Fixes: 4d97f7d53da7dc83 ("inotify: Add flag IN_MASK_CREATE for inotify_add_watch()") Link: https://www.spinics.net/lists/linux-fsdevel/msg140540.html Reported-by: Hulk Robot Signed-off-by: ZhangXiaoxu Reviewed-by: Miao Xie Signed-off-by: Yang Yingliang --- fs/notify/inotify/inotify_user.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c index 780bba695453..73b47cb533f2 100644 --- a/fs/notify/inotify/inotify_user.c +++ b/fs/notify/inotify/inotify_user.c @@ -519,8 +519,10 @@ static int inotify_update_existing_watch(struct fsnotify_group *group, fsn_mark = fsnotify_find_mark(&inode->i_fsnotify_marks, group); if (!fsn_mark) return -ENOENT; - else if (create) - return -EEXIST; + else if (create) { + ret = -EEXIST; + goto out; + } i_mark = container_of(fsn_mark, struct inotify_inode_mark, fsn_mark); @@ -547,7 +549,7 @@ static int inotify_update_existing_watch(struct fsnotify_group *group, /* return the wd */ ret = i_mark->wd; - +out: /* match the get from fsnotify_find_mark() */ fsnotify_put_mark(fsn_mark); -- GitLab