aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/timerfd.c4
-rw-r--r--include/linux/timerfd.h3
2 files changed, 4 insertions, 3 deletions
diff --git a/fs/timerfd.c b/fs/timerfd.c
index c6ef5e33cb34..75d44efe346c 100644
--- a/fs/timerfd.c
+++ b/fs/timerfd.c
@@ -184,7 +184,7 @@ asmlinkage long sys_timerfd_create(int clockid, int flags)
184 int ufd; 184 int ufd;
185 struct timerfd_ctx *ctx; 185 struct timerfd_ctx *ctx;
186 186
187 if (flags & ~TFD_CLOEXEC) 187 if (flags & ~(TFD_CLOEXEC | TFD_NONBLOCK))
188 return -EINVAL; 188 return -EINVAL;
189 if (clockid != CLOCK_MONOTONIC && 189 if (clockid != CLOCK_MONOTONIC &&
190 clockid != CLOCK_REALTIME) 190 clockid != CLOCK_REALTIME)
@@ -199,7 +199,7 @@ asmlinkage long sys_timerfd_create(int clockid, int flags)
199 hrtimer_init(&ctx->tmr, clockid, HRTIMER_MODE_ABS); 199 hrtimer_init(&ctx->tmr, clockid, HRTIMER_MODE_ABS);
200 200
201 ufd = anon_inode_getfd("[timerfd]", &timerfd_fops, ctx, 201 ufd = anon_inode_getfd("[timerfd]", &timerfd_fops, ctx,
202 flags & O_CLOEXEC); 202 flags & (O_CLOEXEC | O_NONBLOCK));
203 if (ufd < 0) 203 if (ufd < 0)
204 kfree(ctx); 204 kfree(ctx);
205 205
diff --git a/include/linux/timerfd.h b/include/linux/timerfd.h
index 96ed97dff00f..86cb0501d3e2 100644
--- a/include/linux/timerfd.h
+++ b/include/linux/timerfd.h
@@ -8,7 +8,7 @@
8#ifndef _LINUX_TIMERFD_H 8#ifndef _LINUX_TIMERFD_H
9#define _LINUX_TIMERFD_H 9#define _LINUX_TIMERFD_H
10 10
11/* For O_CLOEXEC */ 11/* For O_CLOEXEC and O_NONBLOCK */
12#include <linux/fcntl.h> 12#include <linux/fcntl.h>
13 13
14/* Flags for timerfd_settime. */ 14/* Flags for timerfd_settime. */
@@ -16,6 +16,7 @@
16 16
17/* Flags for timerfd_create. */ 17/* Flags for timerfd_create. */
18#define TFD_CLOEXEC O_CLOEXEC 18#define TFD_CLOEXEC O_CLOEXEC
19#define TFD_NONBLOCK O_NONBLOCK
19 20
20 21
21#endif /* _LINUX_TIMERFD_H */ 22#endif /* _LINUX_TIMERFD_H */