Skip to content

Commit 20d9eb3

Browse files
author
Al Viro
committed
convert do_preadv()/do_pwritev()
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 <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent 8152f82 commit 20d9eb3

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

fs/read_write.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,18 +1113,16 @@ static inline loff_t pos_from_hilo(unsigned long high, unsigned long low)
11131113
static ssize_t do_preadv(unsigned long fd, const struct iovec __user *vec,
11141114
unsigned long vlen, loff_t pos, rwf_t flags)
11151115
{
1116-
struct fd f;
11171116
ssize_t ret = -EBADF;
11181117

11191118
if (pos < 0)
11201119
return -EINVAL;
11211120

1122-
f = fdget(fd);
1123-
if (fd_file(f)) {
1121+
CLASS(fd, f)(fd);
1122+
if (!fd_empty(f)) {
11241123
ret = -ESPIPE;
11251124
if (fd_file(f)->f_mode & FMODE_PREAD)
11261125
ret = vfs_readv(fd_file(f), vec, vlen, &pos, flags);
1127-
fdput(f);
11281126
}
11291127

11301128
if (ret > 0)
@@ -1136,18 +1134,16 @@ static ssize_t do_preadv(unsigned long fd, const struct iovec __user *vec,
11361134
static ssize_t do_pwritev(unsigned long fd, const struct iovec __user *vec,
11371135
unsigned long vlen, loff_t pos, rwf_t flags)
11381136
{
1139-
struct fd f;
11401137
ssize_t ret = -EBADF;
11411138

11421139
if (pos < 0)
11431140
return -EINVAL;
11441141

1145-
f = fdget(fd);
1146-
if (fd_file(f)) {
1142+
CLASS(fd, f)(fd);
1143+
if (!fd_empty(f)) {
11471144
ret = -ESPIPE;
11481145
if (fd_file(f)->f_mode & FMODE_PWRITE)
11491146
ret = vfs_writev(fd_file(f), vec, vlen, &pos, flags);
1150-
fdput(f);
11511147
}
11521148

11531149
if (ret > 0)

0 commit comments

Comments
 (0)