Skip to content

Commit 62c9d26

Browse files
z00467499jankara
authored andcommitted
inotify: Fix fsnotify_mark refcount leak in inotify_update_existing_watch()
Commit 4d97f7d ("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: 4d97f7d ("inotify: Add flag IN_MASK_CREATE for inotify_add_watch()") Signed-off-by: ZhangXiaoxu <zhangxiaoxu5@huawei.com> Signed-off-by: Jan Kara <jack@suse.cz>
1 parent 12ad143 commit 62c9d26

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

fs/notify/inotify/inotify_user.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,8 +519,10 @@ static int inotify_update_existing_watch(struct fsnotify_group *group,
519519
fsn_mark = fsnotify_find_mark(&inode->i_fsnotify_marks, group);
520520
if (!fsn_mark)
521521
return -ENOENT;
522-
else if (create)
523-
return -EEXIST;
522+
else if (create) {
523+
ret = -EEXIST;
524+
goto out;
525+
}
524526

525527
i_mark = container_of(fsn_mark, struct inotify_inode_mark, fsn_mark);
526528

@@ -548,6 +550,7 @@ static int inotify_update_existing_watch(struct fsnotify_group *group,
548550
/* return the wd */
549551
ret = i_mark->wd;
550552

553+
out:
551554
/* match the get from fsnotify_find_mark() */
552555
fsnotify_put_mark(fsn_mark);
553556

0 commit comments

Comments
 (0)