Skip to content

Commit

Permalink
preadv/pwritev: switch compat readv/preadv/writev/pwritev from fget t…
Browse files Browse the repository at this point in the history
…o fget_light

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: <linux-api@vger.kernel.org>
Cc: <linux-arch@vger.kernel.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Gerd Hoffmann authored and Linus Torvalds committed Apr 3, 2009
1 parent ddd9e91 commit 10c7db2
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions fs/compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -1222,13 +1222,14 @@ compat_sys_readv(unsigned long fd, const struct compat_iovec __user *vec,
unsigned long vlen)
{
struct file *file;
int fput_needed;
ssize_t ret;

file = fget(fd);
file = fget_light(fd, &fput_needed);
if (!file)
return -EBADF;
ret = compat_readv(file, vec, vlen, &file->f_pos);
fput(file);
fput_light(file, fput_needed);
return ret;
}

Expand All @@ -1238,15 +1239,16 @@ compat_sys_preadv(unsigned long fd, const struct compat_iovec __user *vec,
{
loff_t pos = ((loff_t)pos_high << 32) | pos_low;
struct file *file;
int fput_needed;
ssize_t ret;

if (pos < 0)
return -EINVAL;
file = fget(fd);
file = fget_light(fd, &fput_needed);
if (!file)
return -EBADF;
ret = compat_readv(file, vec, vlen, &pos);
fput(file);
fput_light(file, fput_needed);
return ret;
}

Expand Down Expand Up @@ -1277,13 +1279,14 @@ compat_sys_writev(unsigned long fd, const struct compat_iovec __user *vec,
unsigned long vlen)
{
struct file *file;
int fput_needed;
ssize_t ret;

file = fget(fd);
file = fget_light(fd, &fput_needed);
if (!file)
return -EBADF;
ret = compat_writev(file, vec, vlen, &file->f_pos);
fput(file);
fput_light(file, fput_needed);
return ret;
}

Expand All @@ -1293,15 +1296,16 @@ compat_sys_pwritev(unsigned long fd, const struct compat_iovec __user *vec,
{
loff_t pos = ((loff_t)pos_high << 32) | pos_low;
struct file *file;
int fput_needed;
ssize_t ret;

if (pos < 0)
return -EINVAL;
file = fget(fd);
file = fget_light(fd, &fput_needed);
if (!file)
return -EBADF;
ret = compat_writev(file, vec, vlen, &pos);
fput(file);
fput_light(file, fput_needed);
return ret;
}

Expand Down

0 comments on commit 10c7db2

Please sign in to comment.