diff mbox series

[4/6] fanotify: Simplify cleaning of access_list

Message ID 20190213145443.26836-5-jack@suse.cz (mailing list archive)
State New, archived
Headers show
Series fanotify: Make wait for permission event response interruptible | expand

Commit Message

Jan Kara Feb. 13, 2019, 2:54 p.m. UTC
Simplify iteration cleaning access_list in fanotify_release(). That will
make following changes more obvious.

Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/notify/fanotify/fanotify_user.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

Comments

Amir Goldstein Feb. 13, 2019, 8:25 p.m. UTC | #1
On Wed, Feb 13, 2019 at 4:54 PM Jan Kara <jack@suse.cz> wrote:
>
> Simplify iteration cleaning access_list in fanotify_release(). That will
> make following changes more obvious.
>
> Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>

> ---
>  fs/notify/fanotify/fanotify_user.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
> index 4e36f5642797..96dc469a4086 100644
> --- a/fs/notify/fanotify/fanotify_user.c
> +++ b/fs/notify/fanotify/fanotify_user.c
> @@ -352,7 +352,7 @@ static ssize_t fanotify_write(struct file *file, const char __user *buf, size_t
>  static int fanotify_release(struct inode *ignored, struct file *file)
>  {
>         struct fsnotify_group *group = file->private_data;
> -       struct fanotify_perm_event_info *event, *next;
> +       struct fanotify_perm_event_info *event;
>         struct fsnotify_event *fsn_event;
>
>         /*
> @@ -367,11 +367,9 @@ static int fanotify_release(struct inode *ignored, struct file *file)
>          * and simulate reply from userspace.
>          */
>         spin_lock(&group->notification_lock);
> -       list_for_each_entry_safe(event, next, &group->fanotify_data.access_list,
> -                                fae.fse.list) {
> -               pr_debug("%s: found group=%p event=%p\n", __func__, group,
> -                        event);
> -
> +       while (!list_empty(&group->fanotify_data.access_list)) {
> +               event = list_first_entry(&group->fanotify_data.access_list,
> +                               struct fanotify_perm_event_info, fae.fse.list);
>                 list_del_init(&event->fae.fse.list);
>                 event->response = FAN_ALLOW;
>         }
> --
> 2.16.4
>
diff mbox series

Patch

diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
index 4e36f5642797..96dc469a4086 100644
--- a/fs/notify/fanotify/fanotify_user.c
+++ b/fs/notify/fanotify/fanotify_user.c
@@ -352,7 +352,7 @@  static ssize_t fanotify_write(struct file *file, const char __user *buf, size_t
 static int fanotify_release(struct inode *ignored, struct file *file)
 {
 	struct fsnotify_group *group = file->private_data;
-	struct fanotify_perm_event_info *event, *next;
+	struct fanotify_perm_event_info *event;
 	struct fsnotify_event *fsn_event;
 
 	/*
@@ -367,11 +367,9 @@  static int fanotify_release(struct inode *ignored, struct file *file)
 	 * and simulate reply from userspace.
 	 */
 	spin_lock(&group->notification_lock);
-	list_for_each_entry_safe(event, next, &group->fanotify_data.access_list,
-				 fae.fse.list) {
-		pr_debug("%s: found group=%p event=%p\n", __func__, group,
-			 event);
-
+	while (!list_empty(&group->fanotify_data.access_list)) {
+		event = list_first_entry(&group->fanotify_data.access_list,
+				struct fanotify_perm_event_info, fae.fse.list);
 		list_del_init(&event->fae.fse.list);
 		event->response = FAN_ALLOW;
 	}