aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xattr.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xattr.c')
-rw-r--r--fs/xattr.c52
1 files changed, 22 insertions, 30 deletions
diff --git a/fs/xattr.c b/fs/xattr.c
index 4d45b7189e7e..14a7e2544fe3 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -399,22 +399,20 @@ SYSCALL_DEFINE5(lsetxattr, const char __user *, pathname,
399SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name, 399SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
400 const void __user *,value, size_t, size, int, flags) 400 const void __user *,value, size_t, size, int, flags)
401{ 401{
402 int fput_needed; 402 struct fd f = fdget(fd);
403 struct file *f;
404 struct dentry *dentry; 403 struct dentry *dentry;
405 int error = -EBADF; 404 int error = -EBADF;
406 405
407 f = fget_light(fd, &fput_needed); 406 if (!f.file)
408 if (!f)
409 return error; 407 return error;
410 dentry = f->f_path.dentry; 408 dentry = f.file->f_path.dentry;
411 audit_inode(NULL, dentry); 409 audit_inode(NULL, dentry);
412 error = mnt_want_write_file(f); 410 error = mnt_want_write_file(f.file);
413 if (!error) { 411 if (!error) {
414 error = setxattr(dentry, name, value, size, flags); 412 error = setxattr(dentry, name, value, size, flags);
415 mnt_drop_write_file(f); 413 mnt_drop_write_file(f.file);
416 } 414 }
417 fput_light(f, fput_needed); 415 fdput(f);
418 return error; 416 return error;
419} 417}
420 418
@@ -495,16 +493,14 @@ SYSCALL_DEFINE4(lgetxattr, const char __user *, pathname,
495SYSCALL_DEFINE4(fgetxattr, int, fd, const char __user *, name, 493SYSCALL_DEFINE4(fgetxattr, int, fd, const char __user *, name,
496 void __user *, value, size_t, size) 494 void __user *, value, size_t, size)
497{ 495{
498 int fput_needed; 496 struct fd f = fdget(fd);
499 struct file *f;
500 ssize_t error = -EBADF; 497 ssize_t error = -EBADF;
501 498
502 f = fget_light(fd, &fput_needed); 499 if (!f.file)
503 if (!f)
504 return error; 500 return error;
505 audit_inode(NULL, f->f_path.dentry); 501 audit_inode(NULL, f.file->f_path.dentry);
506 error = getxattr(f->f_path.dentry, name, value, size); 502 error = getxattr(f.file->f_path.dentry, name, value, size);
507 fput_light(f, fput_needed); 503 fdput(f);
508 return error; 504 return error;
509} 505}
510 506
@@ -576,16 +572,14 @@ SYSCALL_DEFINE3(llistxattr, const char __user *, pathname, char __user *, list,
576 572
577SYSCALL_DEFINE3(flistxattr, int, fd, char __user *, list, size_t, size) 573SYSCALL_DEFINE3(flistxattr, int, fd, char __user *, list, size_t, size)
578{ 574{
579 int fput_needed; 575 struct fd f = fdget(fd);
580 struct file *f;
581 ssize_t error = -EBADF; 576 ssize_t error = -EBADF;
582 577
583 f = fget_light(fd, &fput_needed); 578 if (!f.file)
584 if (!f)
585 return error; 579 return error;
586 audit_inode(NULL, f->f_path.dentry); 580 audit_inode(NULL, f.file->f_path.dentry);
587 error = listxattr(f->f_path.dentry, list, size); 581 error = listxattr(f.file->f_path.dentry, list, size);
588 fput_light(f, fput_needed); 582 fdput(f);
589 return error; 583 return error;
590} 584}
591 585
@@ -645,22 +639,20 @@ SYSCALL_DEFINE2(lremovexattr, const char __user *, pathname,
645 639
646SYSCALL_DEFINE2(fremovexattr, int, fd, const char __user *, name) 640SYSCALL_DEFINE2(fremovexattr, int, fd, const char __user *, name)
647{ 641{
648 int fput_needed; 642 struct fd f = fdget(fd);
649 struct file *f;
650 struct dentry *dentry; 643 struct dentry *dentry;
651 int error = -EBADF; 644 int error = -EBADF;
652 645
653 f = fget_light(fd, &fput_needed); 646 if (!f.file)
654 if (!f)
655 return error; 647 return error;
656 dentry = f->f_path.dentry; 648 dentry = f.file->f_path.dentry;
657 audit_inode(NULL, dentry); 649 audit_inode(NULL, dentry);
658 error = mnt_want_write_file(f); 650 error = mnt_want_write_file(f.file);
659 if (!error) { 651 if (!error) {
660 error = removexattr(dentry, name); 652 error = removexattr(dentry, name);
661 mnt_drop_write_file(f); 653 mnt_drop_write_file(f.file);
662 } 654 }
663 fput_light(f, fput_needed); 655 fdput(f);
664 return error; 656 return error;
665} 657}
666 658