[PATCH 4/6] fanotify: only destroy a mark if both its mask and itsignored_mask are cleared

From: Lino Sanfilippo
Date: Thu Dec 02 2010 - 05:09:20 EST



Currently we destroy a mark if one of its masks - event mask or ignored mask - are
cleared without checking if the other mask is also clear.

With this patch we only destroy a mark if both masks are cleared.

Signed-off-by: Lino Sanfilippo <LinoSanfilippo@xxxxxx>
---
fs/notify/fanotify/fanotify_user.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
index c9cd1b9..6b9606a 100644
--- a/fs/notify/fanotify/fanotify_user.c
+++ b/fs/notify/fanotify/fanotify_user.c
@@ -517,6 +517,7 @@ static __u32 fanotify_mark_remove_from_mask(struct fsnotify_mark *fsn_mark,
unsigned int flags)
{
__u32 oldmask;
+ int destroy_mark;

spin_lock(&fsn_mark->lock);
if (!(flags & FAN_MARK_IGNORED_MASK)) {
@@ -526,9 +527,10 @@ static __u32 fanotify_mark_remove_from_mask(struct fsnotify_mark *fsn_mark,
oldmask = fsn_mark->ignored_mask;
fsnotify_set_mark_ignored_mask_locked(fsn_mark, (oldmask & ~mask));
}
+ destroy_mark = (!fsn_mark->mask && !fsn_mark->ignored_mask);
spin_unlock(&fsn_mark->lock);

- if (!(oldmask & ~mask))
+ if (destroy_mark)
fsnotify_destroy_mark(fsn_mark);

return mask & oldmask;
--
1.5.6.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/