aboutsummaryrefslogtreecommitdiffstats
path: root/fs/timerfd.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2012-08-26 21:32:02 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-09-26 21:10:08 -0400
commit4109633f4c4dcdaedf0d85ae74dba334760c577b (patch)
tree862db78eecde7c1db124bd628fa5eadaa3ff3683 /fs/timerfd.c
parent5e196a9cf557dbc2bf808824c6c4998150e18d06 (diff)
switch timerfd_[sg]ettime(2) to fget_light()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/timerfd.c')
-rw-r--r--fs/timerfd.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/fs/timerfd.c b/fs/timerfd.c
index dffeb3795af1..dd91e9420c9e 100644
--- a/fs/timerfd.c
+++ b/fs/timerfd.c
@@ -234,15 +234,15 @@ static const struct file_operations timerfd_fops = {
234 .llseek = noop_llseek, 234 .llseek = noop_llseek,
235}; 235};
236 236
237static struct file *timerfd_fget(int fd) 237static struct file *timerfd_fget(int fd, int *fput_needed)
238{ 238{
239 struct file *file; 239 struct file *file;
240 240
241 file = fget(fd); 241 file = fget_light(fd, fput_needed);
242 if (!file) 242 if (!file)
243 return ERR_PTR(-EBADF); 243 return ERR_PTR(-EBADF);
244 if (file->f_op != &timerfd_fops) { 244 if (file->f_op != &timerfd_fops) {
245 fput(file); 245 fput_light(file, *fput_needed);
246 return ERR_PTR(-EINVAL); 246 return ERR_PTR(-EINVAL);
247 } 247 }
248 248
@@ -287,7 +287,7 @@ SYSCALL_DEFINE4(timerfd_settime, int, ufd, int, flags,
287 struct file *file; 287 struct file *file;
288 struct timerfd_ctx *ctx; 288 struct timerfd_ctx *ctx;
289 struct itimerspec ktmr, kotmr; 289 struct itimerspec ktmr, kotmr;
290 int ret; 290 int ret, fput_needed;
291 291
292 if (copy_from_user(&ktmr, utmr, sizeof(ktmr))) 292 if (copy_from_user(&ktmr, utmr, sizeof(ktmr)))
293 return -EFAULT; 293 return -EFAULT;
@@ -297,7 +297,7 @@ SYSCALL_DEFINE4(timerfd_settime, int, ufd, int, flags,
297 !timespec_valid(&ktmr.it_interval)) 297 !timespec_valid(&ktmr.it_interval))
298 return -EINVAL; 298 return -EINVAL;
299 299
300 file = timerfd_fget(ufd); 300 file = timerfd_fget(ufd, &fput_needed);
301 if (IS_ERR(file)) 301 if (IS_ERR(file))
302 return PTR_ERR(file); 302 return PTR_ERR(file);
303 ctx = file->private_data; 303 ctx = file->private_data;
@@ -334,7 +334,7 @@ SYSCALL_DEFINE4(timerfd_settime, int, ufd, int, flags,
334 ret = timerfd_setup(ctx, flags, &ktmr); 334 ret = timerfd_setup(ctx, flags, &ktmr);
335 335
336 spin_unlock_irq(&ctx->wqh.lock); 336 spin_unlock_irq(&ctx->wqh.lock);
337 fput(file); 337 fput_light(file, fput_needed);
338 if (otmr && copy_to_user(otmr, &kotmr, sizeof(kotmr))) 338 if (otmr && copy_to_user(otmr, &kotmr, sizeof(kotmr)))
339 return -EFAULT; 339 return -EFAULT;
340 340
@@ -346,8 +346,9 @@ SYSCALL_DEFINE2(timerfd_gettime, int, ufd, struct itimerspec __user *, otmr)
346 struct file *file; 346 struct file *file;
347 struct timerfd_ctx *ctx; 347 struct timerfd_ctx *ctx;
348 struct itimerspec kotmr; 348 struct itimerspec kotmr;
349 int fput_needed;
349 350
350 file = timerfd_fget(ufd); 351 file = timerfd_fget(ufd, &fput_needed);
351 if (IS_ERR(file)) 352 if (IS_ERR(file))
352 return PTR_ERR(file); 353 return PTR_ERR(file);
353 ctx = file->private_data; 354 ctx = file->private_data;
@@ -362,7 +363,7 @@ SYSCALL_DEFINE2(timerfd_gettime, int, ufd, struct itimerspec __user *, otmr)
362 kotmr.it_value = ktime_to_timespec(timerfd_get_remaining(ctx)); 363 kotmr.it_value = ktime_to_timespec(timerfd_get_remaining(ctx));
363 kotmr.it_interval = ktime_to_timespec(ctx->tintv); 364 kotmr.it_interval = ktime_to_timespec(ctx->tintv);
364 spin_unlock_irq(&ctx->wqh.lock); 365 spin_unlock_irq(&ctx->wqh.lock);
365 fput(file); 366 fput_light(file, fput_needed);
366 367
367 return copy_to_user(otmr, &kotmr, sizeof(kotmr)) ? -EFAULT: 0; 368 return copy_to_user(otmr, &kotmr, sizeof(kotmr)) ? -EFAULT: 0;
368} 369}