Skip to content

Commit

Permalink
fanotify: only destroy a mark if both its mask and its ignored_mask a…
Browse files Browse the repository at this point in the history
…re cleared

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 <[email protected]>
Signed-off-by: Eric Paris <[email protected]>
  • Loading branch information
LinoSanfilippo333 authored and eparis committed Dec 15, 2010
1 parent 5224f23 commit ef9bf3b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion fs/notify/fanotify/fanotify_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,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)) {
Expand All @@ -528,9 +529,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;
Expand Down

0 comments on commit ef9bf3b

Please sign in to comment.