aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-06-13 00:04:51 -0400
committerTejun Heo <tj@kernel.org>2013-06-13 13:55:17 -0400
commitf4f4be2bd2889c69a8698edef8dbfd4f6759aa87 (patch)
tree4f9bca9bc566527b44b5f3d87fbd93e3de18715a /kernel
parent69d0206c793a17431eacee2694ee7a4b25df76b7 (diff)
cgroup: use kzalloc() instead of kmalloc()
There's no point in using kmalloc() instead of the clearing variant for trivial stuff. We can live dangerously elsewhere. Use kzalloc() instead and drop 0 inits. While at it, do trivial code reorganization in cgroup_file_open(). This patch doesn't introduce any functional changes. v2: I was caught in the very distant past where list_del() didn't poison and the initial version converted list_del()s to list_del_init()s too. Li and Kent took me out of the stasis chamber. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Kent Overstreet <koverstreet@google.com> Acked-by: Li Zefan <lizefan@huawei.com>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/cgroup.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index ef97bd0cd546..d86a8477d56a 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -597,7 +597,7 @@ static int allocate_cgrp_cset_links(int count, struct list_head *tmp_links)
597 INIT_LIST_HEAD(tmp_links); 597 INIT_LIST_HEAD(tmp_links);
598 598
599 for (i = 0; i < count; i++) { 599 for (i = 0; i < count; i++) {
600 link = kmalloc(sizeof(*link), GFP_KERNEL); 600 link = kzalloc(sizeof(*link), GFP_KERNEL);
601 if (!link) { 601 if (!link) {
602 free_cgrp_cset_links(tmp_links); 602 free_cgrp_cset_links(tmp_links);
603 return -ENOMEM; 603 return -ENOMEM;
@@ -658,7 +658,7 @@ static struct css_set *find_css_set(struct css_set *old_cset,
658 if (cset) 658 if (cset)
659 return cset; 659 return cset;
660 660
661 cset = kmalloc(sizeof(*cset), GFP_KERNEL); 661 cset = kzalloc(sizeof(*cset), GFP_KERNEL);
662 if (!cset) 662 if (!cset)
663 return NULL; 663 return NULL;
664 664
@@ -2475,10 +2475,12 @@ static int cgroup_file_open(struct inode *inode, struct file *file)
2475 cft = __d_cft(file->f_dentry); 2475 cft = __d_cft(file->f_dentry);
2476 2476
2477 if (cft->read_map || cft->read_seq_string) { 2477 if (cft->read_map || cft->read_seq_string) {
2478 struct cgroup_seqfile_state *state = 2478 struct cgroup_seqfile_state *state;
2479 kzalloc(sizeof(*state), GFP_USER); 2479
2480 state = kzalloc(sizeof(*state), GFP_USER);
2480 if (!state) 2481 if (!state)
2481 return -ENOMEM; 2482 return -ENOMEM;
2483
2482 state->cft = cft; 2484 state->cft = cft;
2483 state->cgroup = __d_cgrp(file->f_dentry->d_parent); 2485 state->cgroup = __d_cgrp(file->f_dentry->d_parent);
2484 file->f_op = &cgroup_seqfile_operations; 2486 file->f_op = &cgroup_seqfile_operations;
@@ -3511,7 +3513,7 @@ static struct cgroup_pidlist *cgroup_pidlist_find(struct cgroup *cgrp,
3511 } 3513 }
3512 } 3514 }
3513 /* entry not found; create a new one */ 3515 /* entry not found; create a new one */
3514 l = kmalloc(sizeof(struct cgroup_pidlist), GFP_KERNEL); 3516 l = kzalloc(sizeof(struct cgroup_pidlist), GFP_KERNEL);
3515 if (!l) { 3517 if (!l) {
3516 mutex_unlock(&cgrp->pidlist_mutex); 3518 mutex_unlock(&cgrp->pidlist_mutex);
3517 return l; 3519 return l;
@@ -3520,8 +3522,6 @@ static struct cgroup_pidlist *cgroup_pidlist_find(struct cgroup *cgrp,
3520 down_write(&l->mutex); 3522 down_write(&l->mutex);
3521 l->key.type = type; 3523 l->key.type = type;
3522 l->key.ns = get_pid_ns(ns); 3524 l->key.ns = get_pid_ns(ns);
3523 l->use_count = 0; /* don't increment here */
3524 l->list = NULL;
3525 l->owner = cgrp; 3525 l->owner = cgrp;
3526 list_add(&l->links, &cgrp->pidlists); 3526 list_add(&l->links, &cgrp->pidlists);
3527 mutex_unlock(&cgrp->pidlist_mutex); 3527 mutex_unlock(&cgrp->pidlist_mutex);