summaryrefslogtreecommitdiffstats
path: root/fs/proc/generic.c
diff options
context:
space:
mode:
authoryan <clouds.yan@gmail.com>2012-10-04 17:15:43 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2012-10-06 03:05:18 +0900
commit17baa2a2c40f2f0330d25819b589a515d36b2d40 (patch)
treee274bf5906900080e0975ea2196adcf70641f7e1 /fs/proc/generic.c
parent0e06936057674ef3f2bd0b398a32ddc512642992 (diff)
downloadop-kernel-dev-17baa2a2c40f2f0330d25819b589a515d36b2d40.zip
op-kernel-dev-17baa2a2c40f2f0330d25819b589a515d36b2d40.tar.gz
proc: use kzalloc instead of kmalloc and memset
Part of the memory will be written twice after this change, but that should be negligible. [akpm@linux-foundation.org: fix __proc_create() coding-style issues, remove unneeded zero-initialisations] Signed-off-by: yan <clouds.yan@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/proc/generic.c')
-rw-r--r--fs/proc/generic.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/fs/proc/generic.c b/fs/proc/generic.c
index 9e8f631..0d80cef 100644
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -605,7 +605,8 @@ static struct proc_dir_entry *__proc_create(struct proc_dir_entry **parent,
unsigned int len;
/* make sure name is valid */
- if (!name || !strlen(name)) goto out;
+ if (!name || !strlen(name))
+ goto out;
if (xlate_proc_name(name, parent, &fn) != 0)
goto out;
@@ -616,20 +617,18 @@ static struct proc_dir_entry *__proc_create(struct proc_dir_entry **parent,
len = strlen(fn);
- ent = kmalloc(sizeof(struct proc_dir_entry) + len + 1, GFP_KERNEL);
- if (!ent) goto out;
+ ent = kzalloc(sizeof(struct proc_dir_entry) + len + 1, GFP_KERNEL);
+ if (!ent)
+ goto out;
- memset(ent, 0, sizeof(struct proc_dir_entry));
memcpy(ent->name, fn, len + 1);
ent->namelen = len;
ent->mode = mode;
ent->nlink = nlink;
atomic_set(&ent->count, 1);
- ent->pde_users = 0;
spin_lock_init(&ent->pde_unload_lock);
- ent->pde_unload_completion = NULL;
INIT_LIST_HEAD(&ent->pde_openers);
- out:
+out:
return ent;
}
OpenPOWER on IntegriCloud