+ kernel-core-replace-kmallocmemset-with-kzalloc.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled
     kernel core: replace kmalloc+memset with kzalloc
has been added to the -mm tree.  Its filename is
     kernel-core-replace-kmallocmemset-with-kzalloc.patch

See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find
out what to do about this

------------------------------------------------------
Subject: kernel core: replace kmalloc+memset with kzalloc
From: "Burman Yan" <yan_952@xxxxxxxxxxx>



Signed-off-by: Andrew Morton <akpm@xxxxxxxx>
---

 ipc/sem.c            |    3 +--
 kernel/auditfilter.c |    3 +--
 kernel/futex.c       |    3 +--
 kernel/kexec.c       |    3 +--
 lib/kobject.c        |    3 +--
 mm/nommu.c           |    6 ++----
 6 files changed, 7 insertions(+), 14 deletions(-)

diff -puN ipc/sem.c~kernel-core-replace-kmallocmemset-with-kzalloc ipc/sem.c
--- a/ipc/sem.c~kernel-core-replace-kmallocmemset-with-kzalloc
+++ a/ipc/sem.c
@@ -1070,14 +1070,13 @@ static struct sem_undo *find_undo(struct
 	ipc_rcu_getref(sma);
 	sem_unlock(sma);
 
-	new = (struct sem_undo *) kmalloc(sizeof(struct sem_undo) + sizeof(short)*nsems, GFP_KERNEL);
+	new = kzalloc(sizeof(struct sem_undo) + sizeof(short)*nsems, GFP_KERNEL);
 	if (!new) {
 		ipc_lock_by_ptr(&sma->sem_perm);
 		ipc_rcu_putref(sma);
 		sem_unlock(sma);
 		return ERR_PTR(-ENOMEM);
 	}
-	memset(new, 0, sizeof(struct sem_undo) + sizeof(short)*nsems);
 	new->semadj = (short *) &new[1];
 	new->semid = semid;
 
diff -puN kernel/auditfilter.c~kernel-core-replace-kmallocmemset-with-kzalloc kernel/auditfilter.c
--- a/kernel/auditfilter.c~kernel-core-replace-kmallocmemset-with-kzalloc
+++ a/kernel/auditfilter.c
@@ -636,10 +636,9 @@ static struct audit_rule *audit_krule_to
 	struct audit_rule *rule;
 	int i;
 
-	rule = kmalloc(sizeof(*rule), GFP_KERNEL);
+	rule = kzalloc(sizeof(*rule), GFP_KERNEL);
 	if (unlikely(!rule))
 		return NULL;
-	memset(rule, 0, sizeof(*rule));
 
 	rule->flags = krule->flags | krule->listnr;
 	rule->action = krule->action;
diff -puN kernel/futex.c~kernel-core-replace-kmallocmemset-with-kzalloc kernel/futex.c
--- a/kernel/futex.c~kernel-core-replace-kmallocmemset-with-kzalloc
+++ a/kernel/futex.c
@@ -324,12 +324,11 @@ static int refill_pi_state_cache(void)
 	if (likely(current->pi_state_cache))
 		return 0;
 
-	pi_state = kmalloc(sizeof(*pi_state), GFP_KERNEL);
+	pi_state = kzalloc(sizeof(*pi_state), GFP_KERNEL);
 
 	if (!pi_state)
 		return -ENOMEM;
 
-	memset(pi_state, 0, sizeof(*pi_state));
 	INIT_LIST_HEAD(&pi_state->list);
 	/* pi_mutex gets initialized later */
 	pi_state->owner = NULL;
diff -puN kernel/kexec.c~kernel-core-replace-kmallocmemset-with-kzalloc kernel/kexec.c
--- a/kernel/kexec.c~kernel-core-replace-kmallocmemset-with-kzalloc
+++ a/kernel/kexec.c
@@ -108,11 +108,10 @@ static int do_kimage_alloc(struct kimage
 
 	/* Allocate a controlling structure */
 	result = -ENOMEM;
-	image = kmalloc(sizeof(*image), GFP_KERNEL);
+	image = kzalloc(sizeof(*image), GFP_KERNEL);
 	if (!image)
 		goto out;
 
-	memset(image, 0, sizeof(*image));
 	image->head = 0;
 	image->entry = &image->head;
 	image->last_entry = &image->head;
diff -puN lib/kobject.c~kernel-core-replace-kmallocmemset-with-kzalloc lib/kobject.c
--- a/lib/kobject.c~kernel-core-replace-kmallocmemset-with-kzalloc
+++ a/lib/kobject.c
@@ -113,10 +113,9 @@ char *kobject_get_path(struct kobject *k
 	len = get_kobj_path_length(kobj);
 	if (len == 0)
 		return NULL;
-	path = kmalloc(len, gfp_mask);
+	path = kzalloc(len, gfp_mask);
 	if (!path)
 		return NULL;
-	memset(path, 0x00, len);
 	fill_kobj_path(kobj, path, len);
 
 	return path;
diff -puN mm/nommu.c~kernel-core-replace-kmallocmemset-with-kzalloc mm/nommu.c
--- a/mm/nommu.c~kernel-core-replace-kmallocmemset-with-kzalloc
+++ a/mm/nommu.c
@@ -806,10 +806,9 @@ unsigned long do_mmap_pgoff(struct file 
 	vm_flags = determine_vm_flags(file, prot, flags, capabilities);
 
 	/* we're going to need to record the mapping if it works */
-	vml = kmalloc(sizeof(struct vm_list_struct), GFP_KERNEL);
+	vml = kzalloc(sizeof(struct vm_list_struct), GFP_KERNEL);
 	if (!vml)
 		goto error_getting_vml;
-	memset(vml, 0, sizeof(*vml));
 
 	down_write(&nommu_vma_sem);
 
@@ -885,11 +884,10 @@ unsigned long do_mmap_pgoff(struct file 
 	}
 
 	/* we're going to need a VMA struct as well */
-	vma = kmalloc(sizeof(struct vm_area_struct), GFP_KERNEL);
+	vma = kzalloc(sizeof(struct vm_area_struct), GFP_KERNEL);
 	if (!vma)
 		goto error_getting_vma;
 
-	memset(vma, 0, sizeof(*vma));
 	INIT_LIST_HEAD(&vma->anon_vma_node);
 	atomic_set(&vma->vm_usage, 1);
 	if (file)
_

Patches currently in -mm which might be from yan_952@xxxxxxxxxxx are

acpi-replace-kmallocmemset-with-kzalloc.patch
mtd-replace-kmallocmemset-with-kzalloc.patch
serial-replace-kmallocmemset-with-kzalloc.patch
usb-serial-replace-kmallocmemset-with-kzalloc.patch
usb-auerswald-replace-kmallocmemset-with-kzalloc.patch
mtrr-replace-kmallocmemset-with-kzalloc.patch
i386-replace-kmallocmemset-with-kzalloc.patch
kernel-core-replace-kmallocmemset-with-kzalloc.patch
isdn-replace-kmallocmemset-with-kzalloc.patch

-
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Newbies FAQ]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Photo]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux