Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 96988
b: refs/heads/master
c: 9dec3c4
h: refs/heads/master
v: v3
  • Loading branch information
Al Viro committed May 16, 2008
1 parent ccc6864 commit 48823e5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 02afc6267f6d55d47aba9fcafdbd1b7230d2294a
refs/heads/master: 9dec3c4d306b09b31331e475e895bb9674e16d81
24 changes: 16 additions & 8 deletions trunk/fs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ static void copy_fdtable(struct fdtable *nfdt, struct fdtable *ofdt)
unsigned int cpy, set;

BUG_ON(nfdt->max_fds < ofdt->max_fds);
if (ofdt->max_fds == 0)
return;

cpy = ofdt->max_fds * sizeof(struct file *);
set = (nfdt->max_fds - ofdt->max_fds) * sizeof(struct file *);
Expand Down Expand Up @@ -327,14 +325,24 @@ struct files_struct *dup_fd(struct files_struct *oldf, int *errorp)
* Note: we're not a clone task, so the open count won't change.
*/
if (open_files > new_fdt->max_fds) {
new_fdt->max_fds = 0;
spin_unlock(&oldf->file_lock);
spin_lock(&newf->file_lock);
*errorp = expand_files(newf, open_files-1);
spin_unlock(&newf->file_lock);
if (*errorp < 0)

new_fdt = alloc_fdtable(open_files - 1);
if (!new_fdt) {
*errorp = -ENOMEM;
goto out_release;
}

/* beyond sysctl_nr_open; nothing to do */
if (unlikely(new_fdt->max_fds < open_files)) {
free_fdarr(new_fdt);
free_fdset(new_fdt);
kfree(new_fdt);
*errorp = -EMFILE;
goto out_release;
new_fdt = files_fdtable(newf);
}
rcu_assign_pointer(files->fdt, new_fdt);

/*
* Reacquire the oldf lock and a pointer to its fd table
* who knows it may have a new bigger fd table. We need
Expand Down

0 comments on commit 48823e5

Please sign in to comment.