eventfd: only return events requested in poll_mask()
[muen/linux.git] / fs / eventfd.c
index 61c9514da5e956a36a90e9df601eccfc01b9595a..ceb1031f1cac948e74a970f02058cfeb52d7a351 100644 (file)
@@ -156,11 +156,11 @@ static __poll_t eventfd_poll_mask(struct file *file, __poll_t eventmask)
        count = READ_ONCE(ctx->count);
 
        if (count > 0)
-               events |= EPOLLIN;
+               events |= (EPOLLIN & eventmask);
        if (count == ULLONG_MAX)
                events |= EPOLLERR;
        if (ULLONG_MAX - 1 > count)
-               events |= EPOLLOUT;
+               events |= (EPOLLOUT & eventmask);
 
        return events;
 }