From: Kautuk Consul Date: Fri, 16 Dec 2011 04:49:29 +0000 (+1100) Subject: mm/vmalloc.c: eliminate extra loop in pcpu_get_vm_areas error path X-Git-Tag: next-20111221~2^2~236 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=f63d8843f18d65f5dd7ce4e521c5775b6142ec9b;p=karo-tx-linux.git mm/vmalloc.c: eliminate extra loop in pcpu_get_vm_areas error path If either of the vas or vms arrays are not properly kzalloced, then the code jumps to the err_free label. The err_free label runs a loop to check and free each of the array members of the vas and vms arrays which is not required for this situation as none of the array members have been allocated till this point. Eliminate the extra loop we have to go through by introducing a new label err_free2 and then jumping to it. Signed-off-by: Kautuk Consul Acked-by: David Rientjes Signed-off-by: Andrew Morton --- diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 8ae76670fb2c..251ebc8e7a26 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -2378,7 +2378,7 @@ struct vm_struct **pcpu_get_vm_areas(const unsigned long *offsets, vms = kzalloc(sizeof(vms[0]) * nr_vms, GFP_KERNEL); vas = kzalloc(sizeof(vas[0]) * nr_vms, GFP_KERNEL); if (!vas || !vms) - goto err_free; + goto err_free2; for (area = 0; area < nr_vms; area++) { vas[area] = kzalloc(sizeof(struct vmap_area), GFP_KERNEL); @@ -2481,6 +2481,7 @@ err_free: if (vms) kfree(vms[area]); } +err_free2: kfree(vas); kfree(vms); return NULL;