mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 03:27:44 -04:00
fanotify: fix possible false warning when freeing events
When freeing permission events by fsnotify_destroy_event(), the warning WARN_ON(!list_empty(&event->list)); may falsely hit. This is because although fanotify_get_response() saw event->response set, there is nothing to make sure the current CPU also sees the removal of the event from the list. Add proper locking around the WARN_ON() to avoid the false warning. Link: http://lkml.kernel.org/r/[email protected] Reported-by: Miklos Szeredi <[email protected]> Signed-off-by: Jan Kara <[email protected]> Reviewed-by: Lino Sanfilippo <[email protected]> Cc: Eric Paris <[email protected]> Cc: Al Viro <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
073f65522a
commit
0b1b86527d
1 changed files with 11 additions and 2 deletions
|
|
@ -74,8 +74,17 @@ void fsnotify_destroy_event(struct fsnotify_group *group,
|
|||
/* Overflow events are per-group and we don't want to free them */
|
||||
if (!event || event->mask == FS_Q_OVERFLOW)
|
||||
return;
|
||||
/* If the event is still queued, we have a problem... */
|
||||
WARN_ON(!list_empty(&event->list));
|
||||
/*
|
||||
* If the event is still queued, we have a problem... Do an unreliable
|
||||
* lockless check first to avoid locking in the common case. The
|
||||
* locking may be necessary for permission events which got removed
|
||||
* from the list by a different CPU than the one freeing the event.
|
||||
*/
|
||||
if (!list_empty(&event->list)) {
|
||||
spin_lock(&group->notification_lock);
|
||||
WARN_ON(!list_empty(&event->list));
|
||||
spin_unlock(&group->notification_lock);
|
||||
}
|
||||
group->ops->free_event(event);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue