]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
convert do_preadv()/do_pwritev()
authorAl Viro <viro@zeniv.linux.org.uk>
Tue, 23 Jul 2024 01:51:33 +0000 (21:51 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Sun, 3 Nov 2024 06:28:06 +0000 (01:28 -0500)
fdput() can be transposed with add_{r,w}char() and inc_sysc{r,w}();
it's the same story as with do_readv()/do_writev(), only with
fdput() instead of fdput_pos().

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

index deb87457aa767bb7c297450886fea2b03d64ae04..f6e9232eacd8b9a4002a906e45f0e4f5e2b7581b 100644 (file)
@@ -1113,18 +1113,16 @@ static inline loff_t pos_from_hilo(unsigned long high, unsigned long low)
 static ssize_t do_preadv(unsigned long fd, const struct iovec __user *vec,
                         unsigned long vlen, loff_t pos, rwf_t flags)
 {
-       struct fd f;
        ssize_t ret = -EBADF;
 
        if (pos < 0)
                return -EINVAL;
 
-       f = fdget(fd);
-       if (fd_file(f)) {
+       CLASS(fd, f)(fd);
+       if (!fd_empty(f)) {
                ret = -ESPIPE;
                if (fd_file(f)->f_mode & FMODE_PREAD)
                        ret = vfs_readv(fd_file(f), vec, vlen, &pos, flags);
-               fdput(f);
        }
 
        if (ret > 0)
@@ -1136,18 +1134,16 @@ static ssize_t do_preadv(unsigned long fd, const struct iovec __user *vec,
 static ssize_t do_pwritev(unsigned long fd, const struct iovec __user *vec,
                          unsigned long vlen, loff_t pos, rwf_t flags)
 {
-       struct fd f;
        ssize_t ret = -EBADF;
 
        if (pos < 0)
                return -EINVAL;
 
-       f = fdget(fd);
-       if (fd_file(f)) {
+       CLASS(fd, f)(fd);
+       if (!fd_empty(f)) {
                ret = -ESPIPE;
                if (fd_file(f)->f_mode & FMODE_PWRITE)
                        ret = vfs_writev(fd_file(f), vec, vlen, &pos, flags);
-               fdput(f);
        }
 
        if (ret > 0)