Skip to content

Commit

Permalink
[PATCH] fix weird logic in alloc_fdtable()
Browse files Browse the repository at this point in the history
There's a fairly obvious infinite loop in there.

Also, use roundup_pow_of_two() rather than open-coding stuff.

Cc: Eric Dumazet <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Andrew Morton authored and Linus Torvalds committed Jul 10, 2006
1 parent 38e0e8c commit 92eb7a2
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions fs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,9 @@ static struct fdtable *alloc_fdtable(int nr)
if (!fdt)
goto out;

nfds = 8 * L1_CACHE_BYTES;
/* Expand to the max in easy steps */
while (nfds <= nr) {
nfds = nfds * 2;
if (nfds > NR_OPEN)
nfds = NR_OPEN;
}
nfds = max_t(int, 8 * L1_CACHE_BYTES, roundup_pow_of_two(nfds));
if (nfds > NR_OPEN)
nfds = NR_OPEN;

new_openset = alloc_fdset(nfds);
new_execset = alloc_fdset(nfds);
Expand Down

0 comments on commit 92eb7a2

Please sign in to comment.