diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2012-04-21 18:40:32 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-05-29 23:28:29 -0400 |
commit | 863ced7fe762f80e67bc9171e47c7d80032cce12 (patch) | |
tree | 1dc536a701c8d6a3217877d8fedef0d2c56cf1a3 | |
parent | c2bd6c11cd05fed1eeb83230e87351357d72bb48 (diff) |
switch readdir/getdents to fget_light/fput_light
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | fs/compat.c | 33 | ||||
-rw-r--r-- | fs/readdir.c | 33 |
2 files changed, 28 insertions, 38 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); |
889 | out: | ||
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); |
983 | out: | ||
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); |
1072 | out: | ||
1073 | return error; | 1068 | return error; |
1074 | } | 1069 | } |
1075 | #endif /* ! __ARCH_OMIT_COMPAT_SYS_GETDENTS64 */ | 1070 | #endif /* ! __ARCH_OMIT_COMPAT_SYS_GETDENTS64 */ |
diff --git a/fs/readdir.c b/fs/readdir.c index cc0a8227cddf..39e3370d79cf 100644 --- a/fs/readdir.c +++ b/fs/readdir.c | |||
@@ -108,11 +108,11 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd, | |||
108 | int error; | 108 | int error; |
109 | struct file * file; | 109 | struct file * file; |
110 | struct readdir_callback buf; | 110 | struct readdir_callback buf; |
111 | int fput_needed; | ||
111 | 112 | ||
112 | error = -EBADF; | 113 | file = fget_light(fd, &fput_needed); |
113 | file = fget(fd); | ||
114 | if (!file) | 114 | if (!file) |
115 | goto out; | 115 | return -EBADF; |
116 | 116 | ||
117 | buf.result = 0; | 117 | buf.result = 0; |
118 | buf.dirent = dirent; | 118 | buf.dirent = dirent; |
@@ -121,8 +121,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd, | |||
121 | if (buf.result) | 121 | if (buf.result) |
122 | error = buf.result; | 122 | error = buf.result; |
123 | 123 | ||
124 | fput(file); | 124 | fput_light(file, fput_needed); |
125 | out: | ||
126 | return error; | 125 | return error; |
127 | } | 126 | } |
128 | 127 | ||
@@ -195,16 +194,15 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd, | |||
195 | struct file * file; | 194 | struct file * file; |
196 | struct linux_dirent __user * lastdirent; | 195 | struct linux_dirent __user * lastdirent; |
197 | struct getdents_callback buf; | 196 | struct getdents_callback buf; |
197 | int fput_needed; | ||
198 | int error; | 198 | int error; |
199 | 199 | ||
200 | error = -EFAULT; | ||
201 | if (!access_ok(VERIFY_WRITE, dirent, count)) | 200 | if (!access_ok(VERIFY_WRITE, dirent, count)) |
202 | goto out; | 201 | return -EFAULT; |
203 | 202 | ||
204 | error = -EBADF; | 203 | file = fget_light(fd, &fput_needed); |
205 | file = fget(fd); | ||
206 | if (!file) | 204 | if (!file) |
207 | goto out; | 205 | return -EBADF; |
208 | 206 | ||
209 | buf.current_dir = dirent; | 207 | buf.current_dir = dirent; |
210 | buf.previous = NULL; | 208 | buf.previous = NULL; |
@@ -221,8 +219,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd, | |||
221 | else | 219 | else |
222 | error = count - buf.count; | 220 | error = count - buf.count; |
223 | } | 221 | } |
224 | fput(file); | 222 | fput_light(file, fput_needed); |
225 | out: | ||
226 | return error; | 223 | return error; |
227 | } | 224 | } |
228 | 225 | ||
@@ -278,16 +275,15 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd, | |||
278 | struct file * file; | 275 | struct file * file; |
279 | struct linux_dirent64 __user * lastdirent; | 276 | struct linux_dirent64 __user * lastdirent; |
280 | struct getdents_callback64 buf; | 277 | struct getdents_callback64 buf; |
278 | int fput_needed; | ||
281 | int error; | 279 | int error; |
282 | 280 | ||
283 | error = -EFAULT; | ||
284 | if (!access_ok(VERIFY_WRITE, dirent, count)) | 281 | if (!access_ok(VERIFY_WRITE, dirent, count)) |
285 | goto out; | 282 | return -EFAULT; |
286 | 283 | ||
287 | error = -EBADF; | 284 | file = fget_light(fd, &fput_needed); |
288 | file = fget(fd); | ||
289 | if (!file) | 285 | if (!file) |
290 | goto out; | 286 | return -EBADF; |
291 | 287 | ||
292 | buf.current_dir = dirent; | 288 | buf.current_dir = dirent; |
293 | buf.previous = NULL; | 289 | buf.previous = NULL; |
@@ -305,7 +301,6 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd, | |||
305 | else | 301 | else |
306 | error = count - buf.count; | 302 | error = count - buf.count; |
307 | } | 303 | } |
308 | fput(file); | 304 | fput_light(file, fput_needed); |
309 | out: | ||
310 | return error; | 305 | return error; |
311 | } | 306 | } |