switch readdir/getdents to fget_light/fput_light

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Al Viro 2012-04-21 18:40:32 -04:00
parent c2bd6c11cd
commit 863ced7fe7
2 changed files with 28 additions and 38 deletions

View file

@ -871,12 +871,12 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
{
int error;
struct file *file;
int fput_needed;
struct compat_readdir_callback buf;
error = -EBADF;
file = fget(fd);
file = fget_light(fd, &fput_needed);
if (!file)
goto out;
return -EBADF;
buf.result = 0;
buf.dirent = dirent;
@ -885,8 +885,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
if (buf.result)
error = buf.result;
fput(file);
out:
fput_light(file, fput_needed);
return error;
}
@ -953,16 +952,15 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
struct file * file;
struct compat_linux_dirent __user * lastdirent;
struct compat_getdents_callback buf;
int fput_needed;
int error;
error = -EFAULT;
if (!access_ok(VERIFY_WRITE, dirent, count))
goto out;
return -EFAULT;
error = -EBADF;
file = fget(fd);
file = fget_light(fd, &fput_needed);
if (!file)
goto out;
return -EBADF;
buf.current_dir = dirent;
buf.previous = NULL;
@ -979,8 +977,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
else
error = count - buf.count;
}
fput(file);
out:
fput_light(file, fput_needed);
return error;
}
@ -1041,16 +1038,15 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
struct file * file;
struct linux_dirent64 __user * lastdirent;
struct compat_getdents_callback64 buf;
int fput_needed;
int error;
error = -EFAULT;
if (!access_ok(VERIFY_WRITE, dirent, count))
goto out;
return -EFAULT;
error = -EBADF;
file = fget(fd);
file = fget_light(fd, &fput_needed);
if (!file)
goto out;
return -EBADF;
buf.current_dir = dirent;
buf.previous = NULL;
@ -1068,8 +1064,7 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
else
error = count - buf.count;
}
fput(file);
out:
fput_light(file, fput_needed);
return error;
}
#endif /* ! __ARCH_OMIT_COMPAT_SYS_GETDENTS64 */