From c798a7b80388acab8d22e88da0555dc55e3bb21c Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 8 May 2008 21:19:42 -0400 Subject: [PATCH] --- yaml --- r: 96990 b: refs/heads/master c: adbecb128cd2cc5d14b0ebef6d020ced0efd0ec6 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/fs/file.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/[refs] b/[refs] index 45f77fc207da..c50baa84376e 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: afbec7fff4928c273a1f1bb14dfdfdf62688a193 +refs/heads/master: adbecb128cd2cc5d14b0ebef6d020ced0efd0ec6 diff --git a/trunk/fs/file.c b/trunk/fs/file.c index 689d2b6947e3..0f705c7cfefe 100644 --- a/trunk/fs/file.c +++ b/trunk/fs/file.c @@ -308,11 +308,16 @@ struct files_struct *dup_fd(struct files_struct *oldf, int *errorp) /* * Check whether we need to allocate a larger fd array and fd set. - * Note: we're not a clone task, so the open count won't change. */ - if (open_files > new_fdt->max_fds) { + while (unlikely(open_files > new_fdt->max_fds)) { spin_unlock(&oldf->file_lock); + if (new_fdt != &newf->fdtab) { + free_fdarr(new_fdt); + free_fdset(new_fdt); + kfree(new_fdt); + } + new_fdt = alloc_fdtable(open_files - 1); if (!new_fdt) { *errorp = -ENOMEM; @@ -335,6 +340,7 @@ struct files_struct *dup_fd(struct files_struct *oldf, int *errorp) */ spin_lock(&oldf->file_lock); old_fdt = files_fdtable(oldf); + open_files = count_open_files(old_fdt); } old_fds = old_fdt->fd;