summaryrefslogtreecommitdiff
path: root/fs/notify/fanotify
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2019-01-08 15:28:18 +0300
committerJan Kara <jack@suse.cz>2019-02-18 13:49:36 +0300
commitaf6a51130626bfd3e60041d80335b2c31590d56d (patch)
treee8d148b7e1a867a81b42a6e4c644325f6547c07f /fs/notify/fanotify
parent53136b393c918cb14626419d6b626a7416b9cbf6 (diff)
downloadlinux-af6a51130626bfd3e60041d80335b2c31590d56d.tar.xz
fanotify: Fold dequeue_event() into process_access_response()
Fold dequeue_event() into process_access_response(). This will make changes to use of ->response field easier. Reviewed-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/notify/fanotify')
-rw-r--r--fs/notify/fanotify/fanotify_user.c41
1 files changed, 13 insertions, 28 deletions
diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
index 6c61a06d0ef5..e47d2a7709bf 100644
--- a/fs/notify/fanotify/fanotify_user.c
+++ b/fs/notify/fanotify/fanotify_user.c
@@ -138,28 +138,6 @@ static int create_fd(struct fsnotify_group *group,
return client_fd;
}
-static struct fanotify_perm_event *dequeue_event(
- struct fsnotify_group *group, int fd)
-{
- struct fanotify_perm_event *event, *return_e = NULL;
-
- spin_lock(&group->notification_lock);
- list_for_each_entry(event, &group->fanotify_data.access_list,
- fae.fse.list) {
- if (event->fd != fd)
- continue;
-
- list_del_init(&event->fae.fse.list);
- return_e = event;
- break;
- }
- spin_unlock(&group->notification_lock);
-
- pr_debug("%s: found return_re=%p\n", __func__, return_e);
-
- return return_e;
-}
-
static int process_access_response(struct fsnotify_group *group,
struct fanotify_response *response_struct)
{
@@ -188,14 +166,21 @@ static int process_access_response(struct fsnotify_group *group,
if ((response & FAN_AUDIT) && !FAN_GROUP_FLAG(group, FAN_ENABLE_AUDIT))
return -EINVAL;
- event = dequeue_event(group, fd);
- if (!event)
- return -ENOENT;
+ spin_lock(&group->notification_lock);
+ list_for_each_entry(event, &group->fanotify_data.access_list,
+ fae.fse.list) {
+ if (event->fd != fd)
+ continue;
- event->response = response;
- wake_up(&group->fanotify_data.access_waitq);
+ list_del_init(&event->fae.fse.list);
+ event->response = response;
+ spin_unlock(&group->notification_lock);
+ wake_up(&group->fanotify_data.access_waitq);
+ return 0;
+ }
+ spin_unlock(&group->notification_lock);
- return 0;
+ return -ENOENT;
}
static int copy_fid_to_user(struct fanotify_event *event, char __user *buf)