diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2012-08-28 12:52:22 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-09-26 22:20:08 -0400 |
commit | 2903ff019b346ab8d36ebbf54853c3aaf6590608 (patch) | |
tree | 962d94054765bb37bc00e977c3036e65c5fd91fe /fs/fcntl.c | |
parent | a5b470ba06aa3f96999ede5feba178df6bdb134a (diff) |
switch simple cases of fget_light to fdget
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/fcntl.c')
-rw-r--r-- | fs/fcntl.c | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/fs/fcntl.c b/fs/fcntl.c index 40a5bfb72cca..91af39a33af7 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c | |||
@@ -348,25 +348,23 @@ static int check_fcntl_cmd(unsigned cmd) | |||
348 | 348 | ||
349 | SYSCALL_DEFINE3(fcntl, unsigned int, fd, unsigned int, cmd, unsigned long, arg) | 349 | SYSCALL_DEFINE3(fcntl, unsigned int, fd, unsigned int, cmd, unsigned long, arg) |
350 | { | 350 | { |
351 | struct file *filp; | 351 | struct fd f = fdget_raw(fd); |
352 | int fput_needed; | ||
353 | long err = -EBADF; | 352 | long err = -EBADF; |
354 | 353 | ||
355 | filp = fget_raw_light(fd, &fput_needed); | 354 | if (!f.file) |
356 | if (!filp) | ||
357 | goto out; | 355 | goto out; |
358 | 356 | ||
359 | if (unlikely(filp->f_mode & FMODE_PATH)) { | 357 | if (unlikely(f.file->f_mode & FMODE_PATH)) { |
360 | if (!check_fcntl_cmd(cmd)) | 358 | if (!check_fcntl_cmd(cmd)) |
361 | goto out1; | 359 | goto out1; |
362 | } | 360 | } |
363 | 361 | ||
364 | err = security_file_fcntl(filp, cmd, arg); | 362 | err = security_file_fcntl(f.file, cmd, arg); |
365 | if (!err) | 363 | if (!err) |
366 | err = do_fcntl(fd, cmd, arg, filp); | 364 | err = do_fcntl(fd, cmd, arg, f.file); |
367 | 365 | ||
368 | out1: | 366 | out1: |
369 | fput_light(filp, fput_needed); | 367 | fdput(f); |
370 | out: | 368 | out: |
371 | return err; | 369 | return err; |
372 | } | 370 | } |
@@ -375,38 +373,36 @@ out: | |||
375 | SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd, | 373 | SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd, |
376 | unsigned long, arg) | 374 | unsigned long, arg) |
377 | { | 375 | { |
378 | struct file * filp; | 376 | struct fd f = fdget_raw(fd); |
379 | long err = -EBADF; | 377 | long err = -EBADF; |
380 | int fput_needed; | ||
381 | 378 | ||
382 | filp = fget_raw_light(fd, &fput_needed); | 379 | if (!f.file) |
383 | if (!filp) | ||
384 | goto out; | 380 | goto out; |
385 | 381 | ||
386 | if (unlikely(filp->f_mode & FMODE_PATH)) { | 382 | if (unlikely(f.file->f_mode & FMODE_PATH)) { |
387 | if (!check_fcntl_cmd(cmd)) | 383 | if (!check_fcntl_cmd(cmd)) |
388 | goto out1; | 384 | goto out1; |
389 | } | 385 | } |
390 | 386 | ||
391 | err = security_file_fcntl(filp, cmd, arg); | 387 | err = security_file_fcntl(f.file, cmd, arg); |
392 | if (err) | 388 | if (err) |
393 | goto out1; | 389 | goto out1; |
394 | 390 | ||
395 | switch (cmd) { | 391 | switch (cmd) { |
396 | case F_GETLK64: | 392 | case F_GETLK64: |
397 | err = fcntl_getlk64(filp, (struct flock64 __user *) arg); | 393 | err = fcntl_getlk64(f.file, (struct flock64 __user *) arg); |
398 | break; | 394 | break; |
399 | case F_SETLK64: | 395 | case F_SETLK64: |
400 | case F_SETLKW64: | 396 | case F_SETLKW64: |
401 | err = fcntl_setlk64(fd, filp, cmd, | 397 | err = fcntl_setlk64(fd, f.file, cmd, |
402 | (struct flock64 __user *) arg); | 398 | (struct flock64 __user *) arg); |
403 | break; | 399 | break; |
404 | default: | 400 | default: |
405 | err = do_fcntl(fd, cmd, arg, filp); | 401 | err = do_fcntl(fd, cmd, arg, f.file); |
406 | break; | 402 | break; |
407 | } | 403 | } |
408 | out1: | 404 | out1: |
409 | fput_light(filp, fput_needed); | 405 | fdput(f); |
410 | out: | 406 | out: |
411 | return err; | 407 | return err; |
412 | } | 408 | } |