]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mm/vmalloc.c: eliminate extra loop in pcpu_get_vm_areas error path
authorKautuk Consul <consul.kautuk@gmail.com>
Fri, 2 Dec 2011 03:06:57 +0000 (14:06 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Mon, 5 Dec 2011 04:19:07 +0000 (15:19 +1100)
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 <consul.kautuk@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/vmalloc.c

index 050db042b6400402d4ab7aaa2d5a98908779aa5a..66336dc8a88771796f8e17b28d92ee96a32d93d7 100644 (file)
@@ -2376,7 +2376,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);
@@ -2479,6 +2479,7 @@ err_free:
                if (vms)
                        kfree(vms[area]);
        }
+err_free2:
        kfree(vas);
        kfree(vms);
        return NULL;