Skip to content

Commit ee62c6b

Browse files
Sha Zhengjutorvalds
Sha Zhengju
authored andcommitted
eventfd: change int to __u64 in eventfd_signal()
eventfd_ctx->count is an __u64 counter which is allowed to reach ULLONG_MAX. eventfd_write() adds a __u64 value to "count", but the kernel side eventfd_signal() only adds an int value to it. Make them consistent. [[email protected]: update interface documentation] Signed-off-by: Sha Zhengju <[email protected]> Cc: Davide Libenzi <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 71ca97d commit ee62c6b

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

fs/eventfd.c

+4-8
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,16 @@ struct eventfd_ctx {
4646
* value, and we signal this as overflow condition by returining a POLLERR
4747
* to poll(2).
4848
*
49-
* Returns @n in case of success, a non-negative number lower than @n in case
50-
* of overflow, or the following error codes:
51-
*
52-
* -EINVAL : The value of @n is negative.
49+
* Returns the amount by which the counter was incrememnted. This will be less
50+
* than @n if the counter has overflowed.
5351
*/
54-
int eventfd_signal(struct eventfd_ctx *ctx, int n)
52+
__u64 eventfd_signal(struct eventfd_ctx *ctx, __u64 n)
5553
{
5654
unsigned long flags;
5755

58-
if (n < 0)
59-
return -EINVAL;
6056
spin_lock_irqsave(&ctx->wqh.lock, flags);
6157
if (ULLONG_MAX - ctx->count < n)
62-
n = (int) (ULLONG_MAX - ctx->count);
58+
n = ULLONG_MAX - ctx->count;
6359
ctx->count += n;
6460
if (waitqueue_active(&ctx->wqh))
6561
wake_up_locked_poll(&ctx->wqh, POLLIN);

include/linux/eventfd.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void eventfd_ctx_put(struct eventfd_ctx *ctx);
3434
struct file *eventfd_fget(int fd);
3535
struct eventfd_ctx *eventfd_ctx_fdget(int fd);
3636
struct eventfd_ctx *eventfd_ctx_fileget(struct file *file);
37-
int eventfd_signal(struct eventfd_ctx *ctx, int n);
37+
__u64 eventfd_signal(struct eventfd_ctx *ctx, __u64 n);
3838
ssize_t eventfd_ctx_read(struct eventfd_ctx *ctx, int no_wait, __u64 *cnt);
3939
int eventfd_ctx_remove_wait_queue(struct eventfd_ctx *ctx, wait_queue_t *wait,
4040
__u64 *cnt);

0 commit comments

Comments
 (0)