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 <lbassel@codeaurora.org>
(cherry picked from commit 2421717cb10a06814d7bdb431485aa3a5e364f36)
This commit is contained in:
Larry Bassel 2011-10-14 10:36:45 -07:00 committed by Stephen Boyd
parent e188e3e5cb
commit 17dfb1cddc

View file

@ -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)
{