Thread (19 messages) 19 messages, 4 authors, 2012-07-01

Re: [PATCH v2 2/3] mm/sparse: fix possible memory leak

From: Gavin Shan <hidden>
Date: 2012-07-01 13:41:28

On Thu, Jun 28, 2012 at 02:34:29PM -0700, David Rientjes wrote:
On Thu, 28 Jun 2012, Gavin Shan wrote:
quoted
quoted
quoted
+{
+	unsigned long size = SECTIONS_PER_ROOT *
+			     sizeof(struct mem_section);
+
+	if (!section)
+		return;
+
+	if (slab_is_available())
+		kfree(section);
+	else
+		free_bootmem_node(NODE_DATA(nid),
+			virt_to_phys(section), size);
Did you check what happens here if !node_state(nid, N_HIGH_MEMORY)?
I'm sorry that I'm not catching your point. Please explain for more
if necessary.
I'm asking specifically about the free_bootmem_node(NODE_DATA(nid), ...).
Thanks for pointing it out, David.
If this section was allocated in sparse_index_alloc() before 
slab_is_available() with alloc_bootmem_node() and nid is not in 
N_HIGH_MEMORY, will alloc_bootmem_node() fallback to any node or return 
NULL?
Yes, you're right that bootmem allocator will try other nodes if the
specified node can't accomodate the memory allocation. So it's not
safe to free memory by free_bootmem_node().
If it falls back to any node, is it safe to try to free that section by 
passing NODE_DATA(nid) here when it wasn't allocated on that nid?
I think free_bootmem() should be used here :-)

Thanks,
Gavin

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help