]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
powerpc/mm: remove linear mapping if __add_pages() fails in arch_add_memory()
authorDavid Hildenbrand <david@redhat.com>
Wed, 11 Nov 2020 14:53:21 +0000 (15:53 +0100)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 19 Nov 2020 05:56:59 +0000 (16:56 +1100)
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
arch/powerpc/mm/mem.c

index c5755b9efb6453eb21cda70764d147b9f41e34f4..8b946ec68d1baeaa1df46f676f6d4e806b347766 100644 (file)
@@ -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,