aboutsummaryrefslogtreecommitdiffstats
path: root/mm/slub.c
diff options
context:
space:
mode:
authorEric Dumazet <eric.dumazet@gmail.com>2011-12-12 22:57:06 -0500
committerPekka Enberg <penberg@kernel.org>2011-12-13 15:11:21 -0500
commit73736e0387ba0e6d2b703407b4d26168d31516a7 (patch)
tree448f2d85f82462096d55c93f15cea9876665faaa /mm/slub.c
parent25f4379b8c79066c4be0e5995f37f5265733b801 (diff)
slub: fix a possible memleak in __slab_alloc()
Zhihua Che reported a possible memleak in slub allocator on CONFIG_PREEMPT=y builds. It is possible current thread migrates right before disabling irqs in __slab_alloc(). We must check again c->freelist, and perform a normal allocation instead of scratching c->freelist. Many thanks to Zhihua Che for spotting this bug, introduced in 2.6.39 V2: Its also possible an IRQ freed one (or several) object(s) and populated c->freelist, so its not a CONFIG_PREEMPT only problem. Cc: <stable@vger.kernel.org> [2.6.39+] Reported-by: Zhihua Che <zhihua.che@gmail.com> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Acked-by: Christoph Lameter <cl@linux.com> Signed-off-by: Pekka Enberg <penberg@kernel.org>
Diffstat (limited to 'mm/slub.c')
-rw-r--r--mm/slub.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/mm/slub.c b/mm/slub.c
index 108ed03fb422..5e410a95abaf 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -2169,6 +2169,11 @@ redo:
2169 goto new_slab; 2169 goto new_slab;
2170 } 2170 }
2171 2171
2172 /* must check again c->freelist in case of cpu migration or IRQ */
2173 object = c->freelist;
2174 if (object)
2175 goto load_freelist;
2176
2172 stat(s, ALLOC_SLOWPATH); 2177 stat(s, ALLOC_SLOWPATH);
2173 2178
2174 do { 2179 do {