diff options
| -rw-r--r-- | fs/notify/fanotify/fanotify_user.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c index a9ced3feb0bb..cf9c30009825 100644 --- a/fs/notify/fanotify/fanotify_user.c +++ b/fs/notify/fanotify/fanotify_user.c | |||
| @@ -43,17 +43,14 @@ static struct fsnotify_event *get_one_event(struct fsnotify_group *group, | |||
| 43 | return fsnotify_remove_notify_event(group); | 43 | return fsnotify_remove_notify_event(group); |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | static int create_and_fill_fd(struct fsnotify_group *group, | 46 | static int create_fd(struct fsnotify_group *group, struct fsnotify_event *event) |
| 47 | struct fanotify_event_metadata *metadata, | ||
| 48 | struct fsnotify_event *event) | ||
| 49 | { | 47 | { |
| 50 | int client_fd; | 48 | int client_fd; |
| 51 | struct dentry *dentry; | 49 | struct dentry *dentry; |
| 52 | struct vfsmount *mnt; | 50 | struct vfsmount *mnt; |
| 53 | struct file *new_file; | 51 | struct file *new_file; |
| 54 | 52 | ||
| 55 | pr_debug("%s: group=%p metadata=%p event=%p\n", __func__, group, | 53 | pr_debug("%s: group=%p event=%p\n", __func__, group, event); |
| 56 | metadata, event); | ||
| 57 | 54 | ||
| 58 | client_fd = get_unused_fd(); | 55 | client_fd = get_unused_fd(); |
| 59 | if (client_fd < 0) | 56 | if (client_fd < 0) |
| @@ -93,9 +90,7 @@ static int create_and_fill_fd(struct fsnotify_group *group, | |||
| 93 | fd_install(client_fd, new_file); | 90 | fd_install(client_fd, new_file); |
| 94 | } | 91 | } |
| 95 | 92 | ||
| 96 | metadata->fd = client_fd; | 93 | return client_fd; |
| 97 | |||
| 98 | return 0; | ||
| 99 | } | 94 | } |
| 100 | 95 | ||
| 101 | static ssize_t fill_event_metadata(struct fsnotify_group *group, | 96 | static ssize_t fill_event_metadata(struct fsnotify_group *group, |
| @@ -108,9 +103,9 @@ static ssize_t fill_event_metadata(struct fsnotify_group *group, | |||
| 108 | metadata->event_len = FAN_EVENT_METADATA_LEN; | 103 | metadata->event_len = FAN_EVENT_METADATA_LEN; |
| 109 | metadata->vers = FANOTIFY_METADATA_VERSION; | 104 | metadata->vers = FANOTIFY_METADATA_VERSION; |
| 110 | metadata->mask = fanotify_outgoing_mask(event->mask); | 105 | metadata->mask = fanotify_outgoing_mask(event->mask); |
| 106 | metadata->fd = create_fd(group, event); | ||
| 111 | 107 | ||
| 112 | return create_and_fill_fd(group, metadata, event); | 108 | return metadata->fd; |
| 113 | |||
| 114 | } | 109 | } |
| 115 | 110 | ||
| 116 | static ssize_t copy_event_to_user(struct fsnotify_group *group, | 111 | static ssize_t copy_event_to_user(struct fsnotify_group *group, |
| @@ -123,7 +118,7 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group, | |||
| 123 | pr_debug("%s: group=%p event=%p\n", __func__, group, event); | 118 | pr_debug("%s: group=%p event=%p\n", __func__, group, event); |
| 124 | 119 | ||
| 125 | ret = fill_event_metadata(group, &fanotify_event_metadata, event); | 120 | ret = fill_event_metadata(group, &fanotify_event_metadata, event); |
| 126 | if (ret) | 121 | if (ret < 0) |
| 127 | return ret; | 122 | return ret; |
| 128 | 123 | ||
| 129 | if (copy_to_user(buf, &fanotify_event_metadata, FAN_EVENT_METADATA_LEN)) | 124 | if (copy_to_user(buf, &fanotify_event_metadata, FAN_EVENT_METADATA_LEN)) |
