Commit 863ced7f authored by Al Viro's avatar Al Viro

switch readdir/getdents to fget_light/fput_light

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent c2bd6c11
...@@ -871,12 +871,12 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd, ...@@ -871,12 +871,12 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
{ {
int error; int error;
struct file *file; struct file *file;
int fput_needed;
struct compat_readdir_callback buf; struct compat_readdir_callback buf;
error = -EBADF; file = fget_light(fd, &fput_needed);
file = fget(fd);
if (!file) if (!file)
goto out; return -EBADF;
buf.result = 0; buf.result = 0;
buf.dirent = dirent; buf.dirent = dirent;
...@@ -885,8 +885,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd, ...@@ -885,8 +885,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
if (buf.result) if (buf.result)
error = buf.result; error = buf.result;
fput(file); fput_light(file, fput_needed);
out:
return error; return error;
} }
...@@ -953,16 +952,15 @@ asmlinkage long compat_sys_getdents(unsigned int fd, ...@@ -953,16 +952,15 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
struct file * file; struct file * file;
struct compat_linux_dirent __user * lastdirent; struct compat_linux_dirent __user * lastdirent;
struct compat_getdents_callback buf; struct compat_getdents_callback buf;
int fput_needed;
int error; int error;
error = -EFAULT;
if (!access_ok(VERIFY_WRITE, dirent, count)) if (!access_ok(VERIFY_WRITE, dirent, count))
goto out; return -EFAULT;
error = -EBADF; file = fget_light(fd, &fput_needed);
file = fget(fd);
if (!file) if (!file)
goto out; return -EBADF;
buf.current_dir = dirent; buf.current_dir = dirent;
buf.previous = NULL; buf.previous = NULL;
...@@ -979,8 +977,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd, ...@@ -979,8 +977,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
else else
error = count - buf.count; error = count - buf.count;
} }
fput(file); fput_light(file, fput_needed);
out:
return error; return error;
} }
...@@ -1041,16 +1038,15 @@ asmlinkage long compat_sys_getdents64(unsigned int fd, ...@@ -1041,16 +1038,15 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
struct file * file; struct file * file;
struct linux_dirent64 __user * lastdirent; struct linux_dirent64 __user * lastdirent;
struct compat_getdents_callback64 buf; struct compat_getdents_callback64 buf;
int fput_needed;
int error; int error;
error = -EFAULT;
if (!access_ok(VERIFY_WRITE, dirent, count)) if (!access_ok(VERIFY_WRITE, dirent, count))
goto out; return -EFAULT;
error = -EBADF; file = fget_light(fd, &fput_needed);
file = fget(fd);
if (!file) if (!file)
goto out; return -EBADF;
buf.current_dir = dirent; buf.current_dir = dirent;
buf.previous = NULL; buf.previous = NULL;
...@@ -1068,8 +1064,7 @@ asmlinkage long compat_sys_getdents64(unsigned int fd, ...@@ -1068,8 +1064,7 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
else else
error = count - buf.count; error = count - buf.count;
} }
fput(file); fput_light(file, fput_needed);
out:
return error; return error;
} }
#endif /* ! __ARCH_OMIT_COMPAT_SYS_GETDENTS64 */ #endif /* ! __ARCH_OMIT_COMPAT_SYS_GETDENTS64 */
......
...@@ -108,11 +108,11 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd, ...@@ -108,11 +108,11 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
int error; int error;
struct file * file; struct file * file;
struct readdir_callback buf; struct readdir_callback buf;
int fput_needed;
error = -EBADF; file = fget_light(fd, &fput_needed);
file = fget(fd);
if (!file) if (!file)
goto out; return -EBADF;
buf.result = 0; buf.result = 0;
buf.dirent = dirent; buf.dirent = dirent;
...@@ -121,8 +121,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd, ...@@ -121,8 +121,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
if (buf.result) if (buf.result)
error = buf.result; error = buf.result;
fput(file); fput_light(file, fput_needed);
out:
return error; return error;
} }
...@@ -195,16 +194,15 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd, ...@@ -195,16 +194,15 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
struct file * file; struct file * file;
struct linux_dirent __user * lastdirent; struct linux_dirent __user * lastdirent;
struct getdents_callback buf; struct getdents_callback buf;
int fput_needed;
int error; int error;
error = -EFAULT;
if (!access_ok(VERIFY_WRITE, dirent, count)) if (!access_ok(VERIFY_WRITE, dirent, count))
goto out; return -EFAULT;
error = -EBADF; file = fget_light(fd, &fput_needed);
file = fget(fd);
if (!file) if (!file)
goto out; return -EBADF;
buf.current_dir = dirent; buf.current_dir = dirent;
buf.previous = NULL; buf.previous = NULL;
...@@ -221,8 +219,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd, ...@@ -221,8 +219,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
else else
error = count - buf.count; error = count - buf.count;
} }
fput(file); fput_light(file, fput_needed);
out:
return error; return error;
} }
...@@ -278,16 +275,15 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd, ...@@ -278,16 +275,15 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
struct file * file; struct file * file;
struct linux_dirent64 __user * lastdirent; struct linux_dirent64 __user * lastdirent;
struct getdents_callback64 buf; struct getdents_callback64 buf;
int fput_needed;
int error; int error;
error = -EFAULT;
if (!access_ok(VERIFY_WRITE, dirent, count)) if (!access_ok(VERIFY_WRITE, dirent, count))
goto out; return -EFAULT;
error = -EBADF; file = fget_light(fd, &fput_needed);
file = fget(fd);
if (!file) if (!file)
goto out; return -EBADF;
buf.current_dir = dirent; buf.current_dir = dirent;
buf.previous = NULL; buf.previous = NULL;
...@@ -305,7 +301,6 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd, ...@@ -305,7 +301,6 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
else else
error = count - buf.count; error = count - buf.count;
} }
fput(file); fput_light(file, fput_needed);
out:
return error; return error;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment