Commit 3a250629 authored by Dan Williams's avatar Dan Williams Committed by Linus Torvalds

xen/unpopulated-alloc: consolidate pgmap manipulation

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-a75cb6e615a5@oracle.com
Link: https://lkml.kernel.org/r/160272253442.3136502.16683842453317773487.stgit@dwillia2-desk3.amr.corp.intel.comSigned-off-by: default avatarDan Williams <dan.j.williams@intel.com>
Reported-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent f0c0c115
...@@ -27,11 +27,6 @@ static int fill_list(unsigned int nr_pages) ...@@ -27,11 +27,6 @@ static int fill_list(unsigned int nr_pages)
if (!res) if (!res)
return -ENOMEM; return -ENOMEM;
pgmap = kzalloc(sizeof(*pgmap), GFP_KERNEL);
if (!pgmap)
goto err_pgmap;
pgmap->type = MEMORY_DEVICE_GENERIC;
res->name = "Xen scratch"; res->name = "Xen scratch";
res->flags = IORESOURCE_MEM | IORESOURCE_BUSY; res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
...@@ -43,6 +38,11 @@ static int fill_list(unsigned int nr_pages) ...@@ -43,6 +38,11 @@ static int fill_list(unsigned int nr_pages)
goto err_resource; goto err_resource;
} }
pgmap = kzalloc(sizeof(*pgmap), GFP_KERNEL);
if (!pgmap)
goto err_pgmap;
pgmap->type = MEMORY_DEVICE_GENERIC;
pgmap->range = (struct range) { pgmap->range = (struct range) {
.start = res->start, .start = res->start,
.end = res->end, .end = res->end,
...@@ -92,10 +92,10 @@ static int fill_list(unsigned int nr_pages) ...@@ -92,10 +92,10 @@ static int fill_list(unsigned int nr_pages)
return 0; return 0;
err_memremap: err_memremap:
release_resource(res);
err_resource:
kfree(pgmap); kfree(pgmap);
err_pgmap: err_pgmap:
release_resource(res);
err_resource:
kfree(res); kfree(res);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment