]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commit - mm/memblock.c
mm/memblock: fix memory leak on extending regions
authorGavin Shan <shangw@linux.vnet.ibm.com>
Tue, 29 May 2012 22:06:50 +0000 (15:06 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 29 May 2012 23:22:24 +0000 (16:22 -0700)
commit181eb39425f2b9275afcb015eaa547d11f71a02f
tree0ce0f09b5a86931e580a0a6b88e546831c7318ed
parent4e2f07750d9a94e8f23e86408df5ab95be88bf11
mm/memblock: fix memory leak on extending regions

The overall memblock has been organized into the memory regions and
reserved regions.  Initially, the memory regions and reserved regions are
stored in the predetermined arrays of "struct memblock _region".  It's
possible for the arrays to be enlarged when we have newly added regions,
but no free space left there.  The policy here is to create double-sized
array either by slab allocator or memblock allocator.  Unfortunately, we
didn't free the old array, which might be allocated through slab allocator
before.  That would cause memory leak.

The patch introduces 2 variables to trace where (slab or memblock) the
memory and reserved regions come from.  The memory for the memory or
reserved regions will be deallocated by kfree() if that was allocated by
slab allocator.  Thus to fix the memory leak issue.

Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/memblock.c