Skip to content

Commit 55fecb0

Browse files
Al Viroopsiff
authored andcommitted
xattr: switch to CLASS(fd)
[ Upstream commit a718743 ] Reviewed-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Link: https://lore.kernel.org/all/20241002012230.4174585-1-viro@zeniv.linux.org.uk/ [ Neither `fd_file` nor `fd_empty` are available in 6.6.y, so the changes to the check are dropped. Kept the minor formatting change. ] Signed-off-by: Tomasz Kramkowski <tomasz@kramkow.ski> Tested-by: Barry K. Nathan <barryn@pobox.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit 9a3a2ae5efbbcaed37551218abed94e23c537157) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
1 parent 8b94775 commit 55fecb0

1 file changed

Lines changed: 10 additions & 17 deletions

File tree

fs/xattr.c

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -704,9 +704,9 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
704704
int error;
705705

706706
CLASS(fd, f)(fd);
707+
707708
if (!f.file)
708709
return -EBADF;
709-
710710
audit_file(f.file);
711711
error = setxattr_copy(name, &ctx);
712712
if (error)
@@ -816,16 +816,13 @@ SYSCALL_DEFINE4(lgetxattr, const char __user *, pathname,
816816
SYSCALL_DEFINE4(fgetxattr, int, fd, const char __user *, name,
817817
void __user *, value, size_t, size)
818818
{
819-
struct fd f = fdget(fd);
820-
ssize_t error = -EBADF;
819+
CLASS(fd, f)(fd);
821820

822821
if (!f.file)
823-
return error;
822+
return -EBADF;
824823
audit_file(f.file);
825-
error = getxattr(file_mnt_idmap(f.file), f.file->f_path.dentry,
824+
return getxattr(file_mnt_idmap(f.file), f.file->f_path.dentry,
826825
name, value, size);
827-
fdput(f);
828-
return error;
829826
}
830827

831828
/*
@@ -892,15 +889,12 @@ SYSCALL_DEFINE3(llistxattr, const char __user *, pathname, char __user *, list,
892889

893890
SYSCALL_DEFINE3(flistxattr, int, fd, char __user *, list, size_t, size)
894891
{
895-
struct fd f = fdget(fd);
896-
ssize_t error = -EBADF;
892+
CLASS(fd, f)(fd);
897893

898894
if (!f.file)
899-
return error;
895+
return -EBADF;
900896
audit_file(f.file);
901-
error = listxattr(f.file->f_path.dentry, list, size);
902-
fdput(f);
903-
return error;
897+
return listxattr(f.file->f_path.dentry, list, size);
904898
}
905899

906900
/*
@@ -963,12 +957,12 @@ SYSCALL_DEFINE2(lremovexattr, const char __user *, pathname,
963957

964958
SYSCALL_DEFINE2(fremovexattr, int, fd, const char __user *, name)
965959
{
966-
struct fd f = fdget(fd);
960+
CLASS(fd, f)(fd);
967961
char kname[XATTR_NAME_MAX + 1];
968-
int error = -EBADF;
962+
int error;
969963

970964
if (!f.file)
971-
return error;
965+
return -EBADF;
972966
audit_file(f.file);
973967

974968
error = strncpy_from_user(kname, name, sizeof(kname));
@@ -983,7 +977,6 @@ SYSCALL_DEFINE2(fremovexattr, int, fd, const char __user *, name)
983977
f.file->f_path.dentry, kname);
984978
mnt_drop_write_file(f.file);
985979
}
986-
fdput(f);
987980
return error;
988981
}
989982

0 commit comments

Comments
 (0)