kernel/fork.c: avoid division by zero
authorHeinrich Schuchardt <[email protected]>
Thu, 16 Apr 2015 19:47:47 +0000 (12:47 -0700)
committerLinus Torvalds <[email protected]>
Fri, 17 Apr 2015 13:04:07 +0000 (09:04 -0400)
commitac1b398de1ef94aeee8ba87b0120763526572a6e
tree61e32dcc897d25328065dec06ccc3ab944316e9d
parentff691f6e03815dc8f99461ea509df863a879fc3a
kernel/fork.c: avoid division by zero

PAGE_SIZE is not guaranteed to be equal to or less than 8 times the
THREAD_SIZE.

E.g.  architecture hexagon may have page size 1M and thread size 4096.
This would lead to a division by zero in the calculation of max_threads.

With 32-bit calculation there is no solution which delivers valid results
for all possible combinations of the parameters.  The code is only called
once.  Hence a 64-bit calculation can be used as solution.

[[email protected]: use clamp_t(), per Oleg]
Signed-off-by: Heinrich Schuchardt <[email protected]>
Cc: Oleg Nesterov <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Guenter Roeck <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
kernel/fork.c