aboutsummaryrefslogtreecommitdiffstats
path: root/fs/compat.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2012-04-21 18:40:32 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-05-29 23:28:29 -0400
commit863ced7fe762f80e67bc9171e47c7d80032cce12 (patch)
tree1dc536a701c8d6a3217877d8fedef0d2c56cf1a3 /fs/compat.c
parentc2bd6c11cd05fed1eeb83230e87351357d72bb48 (diff)
switch readdir/getdents to fget_light/fput_light
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/compat.c')
-rw-r--r--fs/compat.c33
1 files changed, 14 insertions, 19 deletions
diff --git a/fs/compat.c b/fs/compat.c
index 0781e619a62a..9f77486414bd 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -871,12 +871,12 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
871{ 871{
872 int error; 872 int error;
873 struct file *file; 873 struct file *file;
874 int fput_needed;
874 struct compat_readdir_callback buf; 875 struct compat_readdir_callback buf;
875 876
876 error = -EBADF; 877 file = fget_light(fd, &fput_needed);
877 file = fget(fd);
878 if (!file) 878 if (!file)
879 goto out; 879 return -EBADF;
880 880
881 buf.result = 0; 881 buf.result = 0;
882 buf.dirent = dirent; 882 buf.dirent = dirent;
@@ -885,8 +885,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
885 if (buf.result) 885 if (buf.result)
886 error = buf.result; 886 error = buf.result;
887 887
888 fput(file); 888 fput_light(file, fput_needed);
889out:
890 return error; 889 return error;
891} 890}
892 891
@@ -953,16 +952,15 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
953 struct file * file; 952 struct file * file;
954 struct compat_linux_dirent __user * lastdirent; 953 struct compat_linux_dirent __user * lastdirent;
955 struct compat_getdents_callback buf; 954 struct compat_getdents_callback buf;
955 int fput_needed;
956 int error; 956 int error;
957 957
958 error = -EFAULT;
959 if (!access_ok(VERIFY_WRITE, dirent, count)) 958 if (!access_ok(VERIFY_WRITE, dirent, count))
960 goto out; 959 return -EFAULT;
961 960
962 error = -EBADF; 961 file = fget_light(fd, &fput_needed);
963 file = fget(fd);
964 if (!file) 962 if (!file)
965 goto out; 963 return -EBADF;
966 964
967 buf.current_dir = dirent; 965 buf.current_dir = dirent;
968 buf.previous = NULL; 966 buf.previous = NULL;
@@ -979,8 +977,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
979 else 977 else
980 error = count - buf.count; 978 error = count - buf.count;
981 } 979 }
982 fput(file); 980 fput_light(file, fput_needed);
983out:
984 return error; 981 return error;
985} 982}
986 983
@@ -1041,16 +1038,15 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
1041 struct file * file; 1038 struct file * file;
1042 struct linux_dirent64 __user * lastdirent; 1039 struct linux_dirent64 __user * lastdirent;
1043 struct compat_getdents_callback64 buf; 1040 struct compat_getdents_callback64 buf;
1041 int fput_needed;
1044 int error; 1042 int error;
1045 1043
1046 error = -EFAULT;
1047 if (!access_ok(VERIFY_WRITE, dirent, count)) 1044 if (!access_ok(VERIFY_WRITE, dirent, count))
1048 goto out; 1045 return -EFAULT;
1049 1046
1050 error = -EBADF; 1047 file = fget_light(fd, &fput_needed);
1051 file = fget(fd);
1052 if (!file) 1048 if (!file)
1053 goto out; 1049 return -EBADF;
1054 1050
1055 buf.current_dir = dirent; 1051 buf.current_dir = dirent;
1056 buf.previous = NULL; 1052 buf.previous = NULL;
@@ -1068,8 +1064,7 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
1068 else 1064 else
1069 error = count - buf.count; 1065 error = count - buf.count;
1070 } 1066 }
1071 fput(file); 1067 fput_light(file, fput_needed);
1072out:
1073 return error; 1068 return error;
1074} 1069}
1075#endif /* ! __ARCH_OMIT_COMPAT_SYS_GETDENTS64 */ 1070#endif /* ! __ARCH_OMIT_COMPAT_SYS_GETDENTS64 */