summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Hildenbrand <david@redhat.com>2020-11-11 17:53:21 +0300
committerMichael Ellerman <mpe@ellerman.id.au>2020-11-19 08:56:59 +0300
commitca2c36cae9d48b180ea51259e35ab3d95d327df2 (patch)
tree3e6bfeb288583e18bf893a010fe26b1df5d3a153
parentd8bd9a121c2f2bc8b36da930dc91b69fd2a705e2 (diff)
downloadlinux-ca2c36cae9d48b180ea51259e35ab3d95d327df2.tar.xz
powerpc/mm: remove linear mapping if __add_pages() fails in arch_add_memory()
Let's revert what we did in case something goes wrong and we return an error - as already done on arm64 and s390x. Signed-off-by: David Hildenbrand <david@redhat.com> Reviewed-by: Oscar Salvador <osalvador@suse.de> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/20201111145322.15793-8-david@redhat.com
-rw-r--r--arch/powerpc/mm/mem.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index c5755b9efb64..8b946ec68d1b 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -170,7 +170,10 @@ int __ref arch_add_memory(int nid, u64 start, u64 size,
rc = arch_create_linear_mapping(nid, start, size, params);
if (rc)
return rc;
- return __add_pages(nid, start_pfn, nr_pages, params);
+ rc = __add_pages(nid, start_pfn, nr_pages, params);
+ if (rc)
+ arch_remove_linear_mapping(start, size);
+ return rc;
}
void __ref arch_remove_memory(int nid, u64 start, u64 size,