diff options
Diffstat (limited to 'kernel/pid.c')
| -rw-r--r-- | kernel/pid.c | 22 | 
1 files changed, 18 insertions, 4 deletions
diff --git a/kernel/pid.c b/kernel/pid.c index b13b624e2c49..5d30c87e3c42 100644 --- a/kernel/pid.c +++ b/kernel/pid.c @@ -41,7 +41,19 @@  #include <linux/sched/task.h>  #include <linux/idr.h> -struct pid init_struct_pid = INIT_STRUCT_PID; +struct pid init_struct_pid = { +	.count 		= ATOMIC_INIT(1), +	.tasks		= { +		{ .first = NULL }, +		{ .first = NULL }, +		{ .first = NULL }, +	}, +	.level		= 0, +	.numbers	= { { +		.nr		= 0, +		.ns		= &init_pid_ns, +	}, } +};  int pid_max = PID_MAX_DEFAULT; @@ -193,10 +205,8 @@ struct pid *alloc_pid(struct pid_namespace *ns)  	}  	if (unlikely(is_child_reaper(pid))) { -		if (pid_ns_prepare_proc(ns)) { -			disable_pid_allocation(ns); +		if (pid_ns_prepare_proc(ns))  			goto out_free; -		}  	}  	get_pid_ns(ns); @@ -226,6 +236,10 @@ out_free:  	while (++i <= ns->level)  		idr_remove(&ns->idr, (pid->numbers + i)->nr); +	/* On failure to allocate the first pid, reset the state */ +	if (ns->pid_allocated == PIDNS_ADDING) +		idr_set_cursor(&ns->idr, 0); +  	spin_unlock_irq(&pidmap_lock);  	kmem_cache_free(ns->pid_cachep, pid);  |