diff options
author | yan <clouds.yan@gmail.com> | 2012-10-04 20:15:43 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-10-05 14:05:18 -0400 |
commit | 17baa2a2c40f2f0330d25819b589a515d36b2d40 (patch) | |
tree | e274bf5906900080e0975ea2196adcf70641f7e1 /fs/proc | |
parent | 0e06936057674ef3f2bd0b398a32ddc512642992 (diff) |
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')
-rw-r--r-- | fs/proc/generic.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/fs/proc/generic.c b/fs/proc/generic.c index 9e8f6316430..0d80cef4cfb 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, | |||
605 | unsigned int len; | 605 | unsigned int len; |
606 | 606 | ||
607 | /* make sure name is valid */ | 607 | /* make sure name is valid */ |
608 | if (!name || !strlen(name)) goto out; | 608 | if (!name || !strlen(name)) |
609 | goto out; | ||
609 | 610 | ||
610 | if (xlate_proc_name(name, parent, &fn) != 0) | 611 | if (xlate_proc_name(name, parent, &fn) != 0) |
611 | goto out; | 612 | goto out; |
@@ -616,20 +617,18 @@ static struct proc_dir_entry *__proc_create(struct proc_dir_entry **parent, | |||
616 | 617 | ||
617 | len = strlen(fn); | 618 | len = strlen(fn); |
618 | 619 | ||
619 | ent = kmalloc(sizeof(struct proc_dir_entry) + len + 1, GFP_KERNEL); | 620 | ent = kzalloc(sizeof(struct proc_dir_entry) + len + 1, GFP_KERNEL); |
620 | if (!ent) goto out; | 621 | if (!ent) |
622 | goto out; | ||
621 | 623 | ||
622 | memset(ent, 0, sizeof(struct proc_dir_entry)); | ||
623 | memcpy(ent->name, fn, len + 1); | 624 | memcpy(ent->name, fn, len + 1); |
624 | ent->namelen = len; | 625 | ent->namelen = len; |
625 | ent->mode = mode; | 626 | ent->mode = mode; |
626 | ent->nlink = nlink; | 627 | ent->nlink = nlink; |
627 | atomic_set(&ent->count, 1); | 628 | atomic_set(&ent->count, 1); |
628 | ent->pde_users = 0; | ||
629 | spin_lock_init(&ent->pde_unload_lock); | 629 | spin_lock_init(&ent->pde_unload_lock); |
630 | ent->pde_unload_completion = NULL; | ||
631 | INIT_LIST_HEAD(&ent->pde_openers); | 630 | INIT_LIST_HEAD(&ent->pde_openers); |
632 | out: | 631 | out: |
633 | return ent; | 632 | return ent; |
634 | } | 633 | } |
635 | 634 | ||