From: ZhangXiaoxu <zhangxiaoxu5@huawei.com>
To: <jack@suse.cz>, <amir73il@gmail.com>, <zhangxiaoxu5@huawei.com>
Cc: <linux-fsdevel@vger.kernel.org>
Subject: [PATCH] inotify: Fix fsnotify_mark refcount leak in inotify_update_existing_watch()
Date: Sat, 2 Mar 2019 09:17:32 +0800 [thread overview]
Message-ID: <1551489452-30199-1-git-send-email-zhangxiaoxu5@huawei.com> (raw)
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>
---
fs/notify/inotify/inotify_user.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
index 798f125..3b7b8e9 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);
@@ -548,6 +550,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);
--
2.7.4
next reply other threads:[~2019-03-02 1:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-02 1:17 ZhangXiaoxu [this message]
2019-03-04 1:10 ` [PATCH] inotify: Fix fsnotify_mark refcount leak in inotify_update_existing_watch() zhangxiaoxu (A)
2019-03-11 7:48 ` zhangxiaoxu (A)
2019-03-11 8:36 ` Amir Goldstein
2019-03-11 9:13 ` Jan Kara
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1551489452-30199-1-git-send-email-zhangxiaoxu5@huawei.com \
--to=zhangxiaoxu5@huawei.com \
--cc=amir73il@gmail.com \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).