]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - glsdk/meta-ti-glsdk.git/blob - recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.2/0042-slub-fix-a-possible-memleak-in-__slab_alloc.patch
linux-ti335x-psp 3.2: update to v3.2.11
[glsdk/meta-ti-glsdk.git] / recipes-kernel / linux / linux-ti33x-psp-3.2 / 3.2.2 / 0042-slub-fix-a-possible-memleak-in-__slab_alloc.patch
1 From 7942ee2ec78601a85bc491a0b63dc2e45dfec3a6 Mon Sep 17 00:00:00 2001
2 From: Eric Dumazet <eric.dumazet@gmail.com>
3 Date: Tue, 13 Dec 2011 04:57:06 +0100
4 Subject: [PATCH 042/130] slub: fix a possible memleak in __slab_alloc()
6 commit 73736e0387ba0e6d2b703407b4d26168d31516a7 upstream.
8 Zhihua Che reported a possible memleak in slub allocator on
9 CONFIG_PREEMPT=y builds.
11 It is possible current thread migrates right before disabling irqs in
12 __slab_alloc(). We must check again c->freelist, and perform a normal
13 allocation instead of scratching c->freelist.
15 Many thanks to Zhihua Che for spotting this bug, introduced in 2.6.39
17 V2: Its also possible an IRQ freed one (or several) object(s) and
18 populated c->freelist, so its not a CONFIG_PREEMPT only problem.
20 Reported-by: Zhihua Che <zhihua.che@gmail.com>
21 Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
22 Acked-by: Christoph Lameter <cl@linux.com>
23 Signed-off-by: Pekka Enberg <penberg@kernel.org>
24 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
25 ---
26  mm/slub.c |    5 +++++
27  1 file changed, 5 insertions(+)
29 diff --git a/mm/slub.c b/mm/slub.c
30 index ed3334d..1a919f0 100644
31 --- a/mm/slub.c
32 +++ b/mm/slub.c
33 @@ -2166,6 +2166,11 @@ redo:
34                 goto new_slab;
35         }
36  
37 +       /* must check again c->freelist in case of cpu migration or IRQ */
38 +       object = c->freelist;
39 +       if (object)
40 +               goto load_freelist;
41 +
42         stat(s, ALLOC_SLOWPATH);
43  
44         do {
45 -- 
46 1.7.9.4