diff options
author | David Hildenbrand <david@redhat.com> | 2020-11-11 15:53:21 +0100 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2020-11-19 16:56:59 +1100 |
commit | ca2c36cae9d48b180ea51259e35ab3d95d327df2 (patch) | |
tree | 3e6bfeb288583e18bf893a010fe26b1df5d3a153 /arch/powerpc/mm/mem.c | |
parent | d8bd9a121c2f2bc8b36da930dc91b69fd2a705e2 (diff) | |
download | lwn-ca2c36cae9d48b180ea51259e35ab3d95d327df2.tar.gz lwn-ca2c36cae9d48b180ea51259e35ab3d95d327df2.zip |
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
Diffstat (limited to 'arch/powerpc/mm/mem.c')
-rw-r--r-- | arch/powerpc/mm/mem.c | 5 |
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, |