From 17dfb1cddc8ef2dc6488bbfd932d683fc1708e6c Mon Sep 17 00:00:00 2001 From: Larry Bassel Date: Fri, 14 Oct 2011 10:36:45 -0700 Subject: [PATCH] mm: make physical memory offline work In recent versions, the platform specific physical offline returns the number of bytes offlined, so a value of 0 indicates an error, not success as in older versions. Make sure that the memory for the original memory resource nodes is not freed via kfree, as this memory was obtained from alloc_bootmem very early in the system's life. Change-Id: Iffcdd8be4483e043d7605fce596ed438b15f3e02 Signed-off-by: Larry Bassel (cherry picked from commit 2421717cb10a06814d7bdb431485aa3a5e364f36) --- mm/memory_hotplug.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 1616f9806562..7457b416947f 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1179,9 +1179,9 @@ int __ref physical_remove_memory(u64 start, u64 size) BUG_ON(!res); ret = arch_physical_remove_memory(start, size); - if (ret) { + if (!ret) { kfree(res); - return ret; + return 0; } res->name = "System RAM"; @@ -1190,8 +1190,11 @@ int __ref physical_remove_memory(u64 start, u64 size) res->flags = IORESOURCE_MEM | IORESOURCE_BUSY; res_old = locate_resource(&iomem_resource, res); - if (res_old) - release_memory_resource(res_old); + if (res_old) { + release_resource(res_old); + if (PageSlab(virt_to_head_page(res_old))) + kfree(res_old); + } kfree(res); return ret; @@ -1946,6 +1949,7 @@ repeat: return 0; } + #else int offline_pages(unsigned long start_pfn, unsigned long nr_pages) {