Cleanup fill_list() to keep all the pgmap manipulations in a single
location of the function. Update the exit unwind path accordingly.

Link: http://lore.kernel.org/r/6186fa28-d123-12db-6171-a75cb6e61...@oracle.com

Cc: Juergen Gross <jgr...@suse.com>
Cc: Stefano Stabellini <sstabell...@kernel.org>
Cc: Andrew Morton <a...@linux-foundation.org>
Cc: <xen-de...@lists.xenproject.org>
Reported-by: Boris Ostrovsky <boris.ostrov...@oracle.com>
Signed-off-by: Dan Williams <dan.j.willi...@intel.com>
---
 drivers/xen/unpopulated-alloc.c |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/xen/unpopulated-alloc.c b/drivers/xen/unpopulated-alloc.c
index 8c512ea550bb..75ab5de99868 100644
--- a/drivers/xen/unpopulated-alloc.c
+++ b/drivers/xen/unpopulated-alloc.c
@@ -27,11 +27,6 @@ static int fill_list(unsigned int nr_pages)
        if (!res)
                return -ENOMEM;
 
-       pgmap = kzalloc(sizeof(*pgmap), GFP_KERNEL);
-       if (!pgmap)
-               goto err_pgmap;
-
-       pgmap->type = MEMORY_DEVICE_GENERIC;
        res->name = "Xen scratch";
        res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
 
@@ -43,6 +38,11 @@ static int fill_list(unsigned int nr_pages)
                goto err_resource;
        }
 
+       pgmap = kzalloc(sizeof(*pgmap), GFP_KERNEL);
+       if (!pgmap)
+               goto err_pgmap;
+
+       pgmap->type = MEMORY_DEVICE_GENERIC;
        pgmap->range = (struct range) {
                .start = res->start,
                .end = res->end,
@@ -91,10 +91,10 @@ static int fill_list(unsigned int nr_pages)
        return 0;
 
 err_memremap:
-       release_resource(res);
-err_resource:
        kfree(pgmap);
 err_pgmap:
+       release_resource(res);
+err_resource:
        kfree(res);
        return ret;
 }
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org

Reply via email to