]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
xen/gnttab: add error-handling code on failure of gnttab_resume
authorJulia Lawall <Julia.Lawall@lip6.fr>
Sun, 15 Apr 2012 09:27:12 +0000 (11:27 +0200)
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Tue, 17 Apr 2012 14:29:59 +0000 (10:29 -0400)
Jump to the label ini_nomem as done on the failure of the page allocations
above.

The code at ini_nomem is modified to accommodate different return values.

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
drivers/xen/grant-table.c

index 9f514bb561af6c17c5c276ec93d0c4fc8521ae10..e570c6f67e17c10b3fdf62fafc95e5428af76b4a 100644 (file)
@@ -1115,6 +1115,7 @@ int gnttab_init(void)
        int i;
        unsigned int max_nr_glist_frames, nr_glist_frames;
        unsigned int nr_init_grefs;
+       int ret;
 
        nr_grant_frames = 1;
        boot_max_nr_grant_frames = __max_nr_grant_frames();
@@ -1133,12 +1134,16 @@ int gnttab_init(void)
        nr_glist_frames = (nr_grant_frames * GREFS_PER_GRANT_FRAME + RPP - 1) / RPP;
        for (i = 0; i < nr_glist_frames; i++) {
                gnttab_list[i] = (grant_ref_t *)__get_free_page(GFP_KERNEL);
-               if (gnttab_list[i] == NULL)
+               if (gnttab_list[i] == NULL) {
+                       ret = -ENOMEM;
                        goto ini_nomem;
+               }
        }
 
-       if (gnttab_resume() < 0)
-               return -ENODEV;
+       if (gnttab_resume() < 0) {
+               ret = -ENODEV;
+               goto ini_nomem;
+       }
 
        nr_init_grefs = nr_grant_frames * GREFS_PER_GRANT_FRAME;
 
@@ -1156,7 +1161,7 @@ int gnttab_init(void)
        for (i--; i >= 0; i--)
                free_page((unsigned long)gnttab_list[i]);
        kfree(gnttab_list);
-       return -ENOMEM;
+       return ret;
 }
 EXPORT_SYMBOL_GPL(gnttab_init);