s390/vmemmap: cleanup when vmemmap_populate() fails
authorDavid Hildenbrand <david@redhat.com>
Wed, 22 Jul 2020 09:45:53 +0000 (11:45 +0200)
committerHeiko Carstens <hca@linux.ibm.com>
Mon, 27 Jul 2020 08:33:46 +0000 (10:33 +0200)
Cleanup what we partially added in case vmemmap_populate() fails. For
vmem, this is already handled by vmem_add_mapping().

Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Gerald Schaefer <gerald.schaefer@de.ibm.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20200722094558.9828-5-david@redhat.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
arch/s390/mm/vmem.c

index 43fe1e2eb90eae28e4936ff4adc1ef27e7e9abd0..be32a38bb91fd7de9fbd7a5a6e6e03590b4e59d1 100644 (file)
@@ -332,8 +332,13 @@ static void vmem_remove_range(unsigned long start, unsigned long size)
 int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node,
                struct vmem_altmap *altmap)
 {
+       int ret;
+
        /* We don't care about the node, just use NUMA_NO_NODE on allocations */
-       return add_pagetable(start, end, false);
+       ret = add_pagetable(start, end, false);
+       if (ret)
+               remove_pagetable(start, end, false);
+       return ret;
 }
 
 void vmemmap_free(unsigned long start, unsigned long end,