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 f7f7f09b0b41..ca15fbd391c8 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -403,22 +403,20 @@ SYSCALL_DEFINE5(lsetxattr, const char __user *, pathname,
403SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name, 403SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
404 const void __user *,value, size_t, size, int, flags) 404 const void __user *,value, size_t, size, int, flags)
405{ 405{
406 int fput_needed; 406 struct fd f = fdget(fd);
407 struct file *f;
408 struct dentry *dentry; 407 struct dentry *dentry;
409 int error = -EBADF; 408 int error = -EBADF;
410 409
411 f = fget_light(fd, &fput_needed); 410 if (!f.file)
412 if (!f)
413 return error; 411 return error;
414 dentry = f->f_path.dentry; 412 dentry = f.file->f_path.dentry;
415 audit_inode(NULL, dentry); 413 audit_inode(NULL, dentry);
416 error = mnt_want_write_file(f); 414 error = mnt_want_write_file(f.file);
417 if (!error) { 415 if (!error) {
418 error = setxattr(dentry, name, value, size, flags); 416 error = setxattr(dentry, name, value, size, flags);
419 mnt_drop_write_file(f); 417 mnt_drop_write_file(f.file);
420 } 418 }
421 fput_light(f, fput_needed); 419 fdput(f);
422 return error; 420 return error;
423} 421}
424 422
@@ -502,16 +500,14 @@ SYSCALL_DEFINE4(lgetxattr, const char __user *, pathname,
502SYSCALL_DEFINE4(fgetxattr, int, fd, const char __user *, name, 500SYSCALL_DEFINE4(fgetxattr, int, fd, const char __user *, name,
503 void __user *, value, size_t, size) 501 void __user *, value, size_t, size)
504{ 502{
505 int fput_needed; 503 struct fd f = fdget(fd);
506 struct file *f;
507 ssize_t error = -EBADF; 504 ssize_t error = -EBADF;
508 505
509 f = fget_light(fd, &fput_needed); 506 if (!f.file)
510 if (!f)
511 return error; 507 return error;
512 audit_inode(NULL, f->f_path.dentry); 508 audit_inode(NULL, f.file->f_path.dentry);
513 error = getxattr(f->f_path.dentry, name, value, size); 509 error = getxattr(f.file->f_path.dentry, name, value, size);
514 fput_light(f, fput_needed); 510 fdput(f);
515 return error; 511 return error;
516} 512}
517 513
@@ -583,16 +579,14 @@ SYSCALL_DEFINE3(llistxattr, const char __user *, pathname, char __user *, list,
583 579
584SYSCALL_DEFINE3(flistxattr, int, fd, char __user *, list, size_t, size) 580SYSCALL_DEFINE3(flistxattr, int, fd, char __user *, list, size_t, size)
585{ 581{
586 int fput_needed; 582 struct fd f = fdget(fd);
587 struct file *f;
588 ssize_t error = -EBADF; 583 ssize_t error = -EBADF;
589 584
590 f = fget_light(fd, &fput_needed); 585 if (!f.file)
591 if (!f)
592 return error; 586 return error;
593 audit_inode(NULL, f->f_path.dentry); 587 audit_inode(NULL, f.file->f_path.dentry);
594 error = listxattr(f->f_path.dentry, list, size); 588 error = listxattr(f.file->f_path.dentry, list, size);
595 fput_light(f, fput_needed); 589 fdput(f);
596 return error; 590 return error;
597} 591}
598 592
@@ -652,22 +646,20 @@ SYSCALL_DEFINE2(lremovexattr, const char __user *, pathname,
652 646
653SYSCALL_DEFINE2(fremovexattr, int, fd, const char __user *, name) 647SYSCALL_DEFINE2(fremovexattr, int, fd, const char __user *, name)
654{ 648{
655 int fput_needed; 649 struct fd f = fdget(fd);
656 struct file *f;
657 struct dentry *dentry; 650 struct dentry *dentry;
658 int error = -EBADF; 651 int error = -EBADF;
659 652
660 f = fget_light(fd, &fput_needed); 653 if (!f.file)
661 if (!f)
662 return error; 654 return error;
663 dentry = f->f_path.dentry; 655 dentry = f.file->f_path.dentry;
664 audit_inode(NULL, dentry); 656 audit_inode(NULL, dentry);
665 error = mnt_want_write_file(f); 657 error = mnt_want_write_file(f.file);
666 if (!error) { 658 if (!error) {
667 error = removexattr(dentry, name); 659 error = removexattr(dentry, name);
668 mnt_drop_write_file(f); 660 mnt_drop_write_file(f.file);
669 } 661 }
670 fput_light(f, fput_needed); 662 fdput(f);
671 return error; 663 return error;
672} 664}
673 665