fork.c: fix NULL pointer dereference when nr_threads == threads-max

I happened to forked lots of processes, and hit NULL pointer dereference.
It is because in copy_process() after checking max_threads, 0 is returned
but not -EAGAIN.

The bug is introduced by "CRED: Detach the credentials from task_struct"
(commit f1752eec6145c97163dbce62d17cf5d928e28a27).

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: James Morris <jmorris@namei.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by Li Zefan and committed by Linus Torvalds 04ec93fe b2a740aa

+1
+1
kernel/fork.c
··· 1005 1005 * triggers too late. This doesn't hurt, the check is only there 1006 1006 * to stop root fork bombs. 1007 1007 */ 1008 + retval = -EAGAIN; 1008 1009 if (nr_threads >= max_threads) 1009 1010 goto bad_fork_cleanup_count; 1010 1011