Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 17baa2a2 authored by yan's avatar yan Committed by Linus Torvalds
Browse files

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: default avataryan <clouds.yan@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 0e069360
Loading
Loading
Loading
Loading
+6 −7
Original line number Diff line number Diff line
@@ -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,18 +617,16 @@ 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:
	return ent;