ANDROID: mm/memory_hotplug: Fix error path handling
Correct a resource leak if arch_add_memory() returns failure.
Bug: 243477359
Change-Id: I1dce82a18c2242d7b6fd9fb1fe3a8b2ba67853de
Fixes: 417ac617ea
("ANDROID: mm/memory_hotplug: implement {add/remove}_memory_subsection")
Signed-off-by: Patrick Daly <quic_pdaly@quicinc.com>
Signed-off-by: Chris Goldsworthy <quic_cgoldswo@quicinc.com>
This commit is contained in:

committed by
Treehugger Robot

parent
98e5fb34d1
commit
84a0d243b6
@@ -1156,14 +1156,22 @@ int add_memory_subsection(int nid, u64 start, u64 size)
|
|||||||
|
|
||||||
ret = arch_add_memory(nid, start, size, ¶ms);
|
ret = arch_add_memory(nid, start, size, ¶ms);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
if (IS_ENABLED(CONFIG_ARCH_KEEP_MEMBLOCK))
|
|
||||||
memblock_remove(start, size);
|
|
||||||
pr_err("%s failed to add subsection start 0x%llx size 0x%llx\n",
|
pr_err("%s failed to add subsection start 0x%llx size 0x%llx\n",
|
||||||
__func__, start, size);
|
__func__, start, size);
|
||||||
|
goto err_add_memory;
|
||||||
}
|
}
|
||||||
mem_hotplug_done();
|
mem_hotplug_done();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
err_add_memory:
|
||||||
|
if (IS_ENABLED(CONFIG_ARCH_KEEP_MEMBLOCK))
|
||||||
|
memblock_remove(start, size);
|
||||||
|
|
||||||
|
mem_hotplug_done();
|
||||||
|
|
||||||
|
release_memory_resource(res);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(add_memory_subsection);
|
EXPORT_SYMBOL_GPL(add_memory_subsection);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user