Skip to content

Commit a718743

Browse files
author
Al Viro
committed
xattr: switch to CLASS(fd)
Reviewed-by: Christian Brauner <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent b8cdd25 commit a718743

File tree

1 file changed

+14
-21
lines changed

1 file changed

+14
-21
lines changed

fs/xattr.c

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -697,9 +697,9 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
697697
int error;
698698

699699
CLASS(fd, f)(fd);
700-
if (!fd_file(f))
701-
return -EBADF;
702700

701+
if (fd_empty(f))
702+
return -EBADF;
703703
audit_file(fd_file(f));
704704
error = setxattr_copy(name, &ctx);
705705
if (error)
@@ -809,16 +809,13 @@ SYSCALL_DEFINE4(lgetxattr, const char __user *, pathname,
809809
SYSCALL_DEFINE4(fgetxattr, int, fd, const char __user *, name,
810810
void __user *, value, size_t, size)
811811
{
812-
struct fd f = fdget(fd);
813-
ssize_t error = -EBADF;
812+
CLASS(fd, f)(fd);
814813

815-
if (!fd_file(f))
816-
return error;
814+
if (fd_empty(f))
815+
return -EBADF;
817816
audit_file(fd_file(f));
818-
error = getxattr(file_mnt_idmap(fd_file(f)), fd_file(f)->f_path.dentry,
817+
return getxattr(file_mnt_idmap(fd_file(f)), fd_file(f)->f_path.dentry,
819818
name, value, size);
820-
fdput(f);
821-
return error;
822819
}
823820

824821
/*
@@ -885,15 +882,12 @@ SYSCALL_DEFINE3(llistxattr, const char __user *, pathname, char __user *, list,
885882

886883
SYSCALL_DEFINE3(flistxattr, int, fd, char __user *, list, size_t, size)
887884
{
888-
struct fd f = fdget(fd);
889-
ssize_t error = -EBADF;
885+
CLASS(fd, f)(fd);
890886

891-
if (!fd_file(f))
892-
return error;
887+
if (fd_empty(f))
888+
return -EBADF;
893889
audit_file(fd_file(f));
894-
error = listxattr(fd_file(f)->f_path.dentry, list, size);
895-
fdput(f);
896-
return error;
890+
return listxattr(fd_file(f)->f_path.dentry, list, size);
897891
}
898892

899893
/*
@@ -950,12 +944,12 @@ SYSCALL_DEFINE2(lremovexattr, const char __user *, pathname,
950944

951945
SYSCALL_DEFINE2(fremovexattr, int, fd, const char __user *, name)
952946
{
953-
struct fd f = fdget(fd);
947+
CLASS(fd, f)(fd);
954948
char kname[XATTR_NAME_MAX + 1];
955-
int error = -EBADF;
949+
int error;
956950

957-
if (!fd_file(f))
958-
return error;
951+
if (fd_empty(f))
952+
return -EBADF;
959953
audit_file(fd_file(f));
960954

961955
error = strncpy_from_user(kname, name, sizeof(kname));
@@ -970,7 +964,6 @@ SYSCALL_DEFINE2(fremovexattr, int, fd, const char __user *, name)
970964
fd_file(f)->f_path.dentry, kname);
971965
mnt_drop_write_file(fd_file(f));
972966
}
973-
fdput(f);
974967
return error;
975968
}
976969

0 commit comments

Comments
 (0)