fix off-by-one in argument passed by iterate_fd() to callbacks
Noticed by Pavel Roskin; the thing in his patch I disagree with was compensating for that shite in callbacks instead of fixing it once in the iterator itself. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
21d8a15ac3
commit
a77cfcb429
14
fs/file.c
14
fs/file.c
@ -994,16 +994,18 @@ int iterate_fd(struct files_struct *files, unsigned n,
|
|||||||
const void *p)
|
const void *p)
|
||||||
{
|
{
|
||||||
struct fdtable *fdt;
|
struct fdtable *fdt;
|
||||||
struct file *file;
|
|
||||||
int res = 0;
|
int res = 0;
|
||||||
if (!files)
|
if (!files)
|
||||||
return 0;
|
return 0;
|
||||||
spin_lock(&files->file_lock);
|
spin_lock(&files->file_lock);
|
||||||
fdt = files_fdtable(files);
|
for (fdt = files_fdtable(files); n < fdt->max_fds; n++) {
|
||||||
while (!res && n < fdt->max_fds) {
|
struct file *file;
|
||||||
file = rcu_dereference_check_fdtable(files, fdt->fd[n++]);
|
file = rcu_dereference_check_fdtable(files, fdt->fd[n]);
|
||||||
if (file)
|
if (!file)
|
||||||
res = f(p, file, n);
|
continue;
|
||||||
|
res = f(p, file, n);
|
||||||
|
if (res)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
spin_unlock(&files->file_lock);
|
spin_unlock(&files->file_lock);
|
||||||
return res;
|
return res;
|
||||||
|
Loading…
Reference in New Issue
Block a user