[PATCH] kernel core: replace kmalloc+memset with kzalloc
Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
parent
304e61e6fb
commit
4668edc334
6 changed files with 7 additions and 14 deletions
|
@ -1070,14 +1070,13 @@ static struct sem_undo *find_undo(struct ipc_namespace *ns, int semid)
|
||||||
ipc_rcu_getref(sma);
|
ipc_rcu_getref(sma);
|
||||||
sem_unlock(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) {
|
if (!new) {
|
||||||
ipc_lock_by_ptr(&sma->sem_perm);
|
ipc_lock_by_ptr(&sma->sem_perm);
|
||||||
ipc_rcu_putref(sma);
|
ipc_rcu_putref(sma);
|
||||||
sem_unlock(sma);
|
sem_unlock(sma);
|
||||||
return ERR_PTR(-ENOMEM);
|
return ERR_PTR(-ENOMEM);
|
||||||
}
|
}
|
||||||
memset(new, 0, sizeof(struct sem_undo) + sizeof(short)*nsems);
|
|
||||||
new->semadj = (short *) &new[1];
|
new->semadj = (short *) &new[1];
|
||||||
new->semid = semid;
|
new->semid = semid;
|
||||||
|
|
||||||
|
|
|
@ -636,10 +636,9 @@ static struct audit_rule *audit_krule_to_rule(struct audit_krule *krule)
|
||||||
struct audit_rule *rule;
|
struct audit_rule *rule;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
rule = kmalloc(sizeof(*rule), GFP_KERNEL);
|
rule = kzalloc(sizeof(*rule), GFP_KERNEL);
|
||||||
if (unlikely(!rule))
|
if (unlikely(!rule))
|
||||||
return NULL;
|
return NULL;
|
||||||
memset(rule, 0, sizeof(*rule));
|
|
||||||
|
|
||||||
rule->flags = krule->flags | krule->listnr;
|
rule->flags = krule->flags | krule->listnr;
|
||||||
rule->action = krule->action;
|
rule->action = krule->action;
|
||||||
|
|
|
@ -324,12 +324,11 @@ static int refill_pi_state_cache(void)
|
||||||
if (likely(current->pi_state_cache))
|
if (likely(current->pi_state_cache))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
pi_state = kmalloc(sizeof(*pi_state), GFP_KERNEL);
|
pi_state = kzalloc(sizeof(*pi_state), GFP_KERNEL);
|
||||||
|
|
||||||
if (!pi_state)
|
if (!pi_state)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
memset(pi_state, 0, sizeof(*pi_state));
|
|
||||||
INIT_LIST_HEAD(&pi_state->list);
|
INIT_LIST_HEAD(&pi_state->list);
|
||||||
/* pi_mutex gets initialized later */
|
/* pi_mutex gets initialized later */
|
||||||
pi_state->owner = NULL;
|
pi_state->owner = NULL;
|
||||||
|
|
|
@ -108,11 +108,10 @@ static int do_kimage_alloc(struct kimage **rimage, unsigned long entry,
|
||||||
|
|
||||||
/* Allocate a controlling structure */
|
/* Allocate a controlling structure */
|
||||||
result = -ENOMEM;
|
result = -ENOMEM;
|
||||||
image = kmalloc(sizeof(*image), GFP_KERNEL);
|
image = kzalloc(sizeof(*image), GFP_KERNEL);
|
||||||
if (!image)
|
if (!image)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
memset(image, 0, sizeof(*image));
|
|
||||||
image->head = 0;
|
image->head = 0;
|
||||||
image->entry = &image->head;
|
image->entry = &image->head;
|
||||||
image->last_entry = &image->head;
|
image->last_entry = &image->head;
|
||||||
|
|
|
@ -111,10 +111,9 @@ char *kobject_get_path(struct kobject *kobj, gfp_t gfp_mask)
|
||||||
len = get_kobj_path_length(kobj);
|
len = get_kobj_path_length(kobj);
|
||||||
if (len == 0)
|
if (len == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
path = kmalloc(len, gfp_mask);
|
path = kzalloc(len, gfp_mask);
|
||||||
if (!path)
|
if (!path)
|
||||||
return NULL;
|
return NULL;
|
||||||
memset(path, 0x00, len);
|
|
||||||
fill_kobj_path(kobj, path, len);
|
fill_kobj_path(kobj, path, len);
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
|
|
|
@ -808,10 +808,9 @@ unsigned long do_mmap_pgoff(struct file *file,
|
||||||
vm_flags = determine_vm_flags(file, prot, flags, capabilities);
|
vm_flags = determine_vm_flags(file, prot, flags, capabilities);
|
||||||
|
|
||||||
/* we're going to need to record the mapping if it works */
|
/* 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)
|
if (!vml)
|
||||||
goto error_getting_vml;
|
goto error_getting_vml;
|
||||||
memset(vml, 0, sizeof(*vml));
|
|
||||||
|
|
||||||
down_write(&nommu_vma_sem);
|
down_write(&nommu_vma_sem);
|
||||||
|
|
||||||
|
@ -887,11 +886,10 @@ unsigned long do_mmap_pgoff(struct file *file,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* we're going to need a VMA struct as well */
|
/* 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)
|
if (!vma)
|
||||||
goto error_getting_vma;
|
goto error_getting_vma;
|
||||||
|
|
||||||
memset(vma, 0, sizeof(*vma));
|
|
||||||
INIT_LIST_HEAD(&vma->anon_vma_node);
|
INIT_LIST_HEAD(&vma->anon_vma_node);
|
||||||
atomic_set(&vma->vm_usage, 1);
|
atomic_set(&vma->vm_usage, 1);
|
||||||
if (file)
|
if (file)
|
||||||
|
|
Loading…
Reference in a new issue