Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

inotify: Fix fsnotify_mark refcount leak in inotify_update_existing_watch()

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()")
Signed-off-by: ZhangXiaoxu <zhangxiaoxu5@huawei.com>
Signed-off-by: Jan Kara <jack@suse.cz>

authored by

ZhangXiaoxu and committed by
Jan Kara
62c9d267 12ad143e

+5 -2
+5 -2
fs/notify/inotify/inotify_user.c
··· 519 519 fsn_mark = fsnotify_find_mark(&inode->i_fsnotify_marks, group); 520 520 if (!fsn_mark) 521 521 return -ENOENT; 522 - else if (create) 523 - return -EEXIST; 522 + else if (create) { 523 + ret = -EEXIST; 524 + goto out; 525 + } 524 526 525 527 i_mark = container_of(fsn_mark, struct inotify_inode_mark, fsn_mark); 526 528 ··· 550 548 /* return the wd */ 551 549 ret = i_mark->wd; 552 550 551 + out: 553 552 /* match the get from fsnotify_find_mark() */ 554 553 fsnotify_put_mark(fsn_mark); 555 554