2010-12-10 17:46:49

by Lino Sanfilippo

[permalink] [raw]
Subject: [PATCH 1/2] fanotify: fix broken ref count in create_fd()


In create_fd(), before we fallback to open a file read-only we should grab dentry
and mount refs again, since they have been put by the former failed call to dentry_open().

Signed-off-by: Lino Sanfilippo <[email protected]>
---
fs/notify/fanotify/fanotify_user.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)

Please apply this against commit 26552d4aa4117cd3ea8cbe13ebf317da652e6bfd of
branch 'origin/for-next' from git.infradead.org/users/eparis/notify.git

diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
index 2d4925b..e108960 100644
--- a/fs/notify/fanotify/fanotify_user.c
+++ b/fs/notify/fanotify/fanotify_user.c
@@ -92,6 +92,10 @@ static int create_fd(struct fsnotify_group *group, struct fsnotify_event *event)
* in order to at least provide something to the listener.
*/
if (IS_ERR(new_file) && group->fanotify_data.readonly_fallback) {
+ /* dentry_open() put our refs, so get them again... */
+ dentry = dget(event->path.dentry);
+ mnt = mntget(event->path.mnt);
+
flags &= ~O_ACCMODE;
flags |= O_RDONLY;
new_file = dentry_open(dentry, mnt, flags,
--
1.5.6.5