From: Pavel Emelyanov Date: Fri, 25 Jul 2008 08:48:42 +0000 (-0700) Subject: pidns: use kzalloc when allocating new pid_namespace struct X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=84406c153a5bfa5d8b428a0933e9d39db6b59a75;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git pidns: use kzalloc when allocating new pid_namespace struct It makes many fields initialization implicit helping in auto-setting #ifdef-ed fields (bsd-acct related pointer will be such). Signed-off-by: Pavel Emelyanov Cc: Balbir Singh Cc: "Eric W. Biederman" Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c index 98702b4b8851..06331cc1c3f5 100644 --- a/kernel/pid_namespace.c +++ b/kernel/pid_namespace.c @@ -71,7 +71,7 @@ static struct pid_namespace *create_pid_namespace(unsigned int level) struct pid_namespace *ns; int i; - ns = kmem_cache_alloc(pid_ns_cachep, GFP_KERNEL); + ns = kmem_cache_zalloc(pid_ns_cachep, GFP_KERNEL); if (ns == NULL) goto out; @@ -84,17 +84,13 @@ static struct pid_namespace *create_pid_namespace(unsigned int level) goto out_free_map; kref_init(&ns->kref); - ns->last_pid = 0; - ns->child_reaper = NULL; ns->level = level; set_bit(0, ns->pidmap[0].page); atomic_set(&ns->pidmap[0].nr_free, BITS_PER_PAGE - 1); - for (i = 1; i < PIDMAP_ENTRIES; i++) { - ns->pidmap[i].page = NULL; + for (i = 1; i < PIDMAP_ENTRIES; i++) atomic_set(&ns->pidmap[i].nr_free, BITS_PER_PAGE); - } return ns;