aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/notify/fanotify/fanotify_user.c46
1 files changed, 24 insertions, 22 deletions
diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
index 2a57278afb80..f1097f56137e 100644
--- a/fs/notify/fanotify/fanotify_user.c
+++ b/fs/notify/fanotify/fanotify_user.c
@@ -275,35 +275,37 @@ static ssize_t fanotify_read(struct file *file, char __user *buf,
275 kevent = get_one_event(group, count); 275 kevent = get_one_event(group, count);
276 mutex_unlock(&group->notification_mutex); 276 mutex_unlock(&group->notification_mutex);
277 277
278 if (kevent) { 278 if (IS_ERR(kevent)) {
279 ret = PTR_ERR(kevent); 279 ret = PTR_ERR(kevent);
280 if (IS_ERR(kevent)) 280 break;
281 }
282
283 if (!kevent) {
284 ret = -EAGAIN;
285 if (file->f_flags & O_NONBLOCK)
281 break; 286 break;
282 ret = copy_event_to_user(group, kevent, buf); 287
283 /* 288 ret = -ERESTARTSYS;
284 * Permission events get queued to wait for response. 289 if (signal_pending(current))
285 * Other events can be destroyed now. 290 break;
286 */ 291
287 if (!(kevent->mask & FAN_ALL_PERM_EVENTS)) 292 if (start != buf)
288 fsnotify_destroy_event(group, kevent);
289 if (ret < 0)
290 break; 293 break;
291 buf += ret; 294 schedule();
292 count -= ret;
293 continue; 295 continue;
294 } 296 }
295 297
296 ret = -EAGAIN; 298 ret = copy_event_to_user(group, kevent, buf);
297 if (file->f_flags & O_NONBLOCK) 299 /*
298 break; 300 * Permission events get queued to wait for response. Other
299 ret = -ERESTARTSYS; 301 * events can be destroyed now.
300 if (signal_pending(current)) 302 */
301 break; 303 if (!(kevent->mask & FAN_ALL_PERM_EVENTS))
302 304 fsnotify_destroy_event(group, kevent);
303 if (start != buf) 305 if (ret < 0)
304 break; 306 break;
305 307 buf += ret;
306 schedule(); 308 count -= ret;
307 } 309 }
308 310
309 finish_wait(&group->notification_waitq, &wait); 311 finish_wait(&group->notification_waitq, &wait);