Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

xattr: switch to CLASS(fd)

Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Al Viro a7187437 b8cdd253

+14 -21
+14 -21
fs/xattr.c
··· 697 697 int error; 698 698 699 699 CLASS(fd, f)(fd); 700 - if (!fd_file(f)) 701 - return -EBADF; 702 700 701 + if (fd_empty(f)) 702 + return -EBADF; 703 703 audit_file(fd_file(f)); 704 704 error = setxattr_copy(name, &ctx); 705 705 if (error) ··· 809 809 SYSCALL_DEFINE4(fgetxattr, int, fd, const char __user *, name, 810 810 void __user *, value, size_t, size) 811 811 { 812 - struct fd f = fdget(fd); 813 - ssize_t error = -EBADF; 812 + CLASS(fd, f)(fd); 814 813 815 - if (!fd_file(f)) 816 - return error; 814 + if (fd_empty(f)) 815 + return -EBADF; 817 816 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, 819 818 name, value, size); 820 - fdput(f); 821 - return error; 822 819 } 823 820 824 821 /* ··· 882 885 883 886 SYSCALL_DEFINE3(flistxattr, int, fd, char __user *, list, size_t, size) 884 887 { 885 - struct fd f = fdget(fd); 886 - ssize_t error = -EBADF; 888 + CLASS(fd, f)(fd); 887 889 888 - if (!fd_file(f)) 889 - return error; 890 + if (fd_empty(f)) 891 + return -EBADF; 890 892 audit_file(fd_file(f)); 891 - error = listxattr(fd_file(f)->f_path.dentry, list, size); 892 - fdput(f); 893 - return error; 893 + return listxattr(fd_file(f)->f_path.dentry, list, size); 894 894 } 895 895 896 896 /* ··· 944 950 945 951 SYSCALL_DEFINE2(fremovexattr, int, fd, const char __user *, name) 946 952 { 947 - struct fd f = fdget(fd); 953 + CLASS(fd, f)(fd); 948 954 char kname[XATTR_NAME_MAX + 1]; 949 - int error = -EBADF; 955 + int error; 950 956 951 - if (!fd_file(f)) 952 - return error; 957 + if (fd_empty(f)) 958 + return -EBADF; 953 959 audit_file(fd_file(f)); 954 960 955 961 error = strncpy_from_user(kname, name, sizeof(kname)); ··· 964 970 fd_file(f)->f_path.dentry, kname); 965 971 mnt_drop_write_file(fd_file(f)); 966 972 } 967 - fdput(f); 968 973 return error; 969 974 } 970 975