1 From 09c2e76ed734a1d36470d257a778aaba28e86531 Mon Sep 17 00:00:00 2001
2 From: Christoph Lameter <cl@linux.com>
3 Date: Tue, 8 Jan 2019 15:23:00 -0800
4 Subject: slab: alien caches must not be initialized if the allocation of the alien cache failed
6 From: Christoph Lameter <cl@linux.com>
8 commit 09c2e76ed734a1d36470d257a778aaba28e86531 upstream.
10 Callers of __alloc_alien() check for NULL. We must do the same check in
11 __alloc_alien_cache to avoid NULL pointer dereferences on allocation
14 Link: http://lkml.kernel.org/r/010001680f42f192-82b4e12e-1565-4ee0-ae1f-1e98974906aa-000000@email.amazonses.com
15 Fixes: 49dfc304ba241 ("slab: use the lock on alien_cache, instead of the lock on array_cache")
16 Fixes: c8522a3a5832b ("Slab: introduce alloc_alien")
17 Signed-off-by: Christoph Lameter <cl@linux.com>
18 Reported-by: syzbot+d6ed4ec679652b4fd4e4@syzkaller.appspotmail.com
19 Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
20 Cc: Pekka Enberg <penberg@kernel.org>
21 Cc: David Rientjes <rientjes@google.com>
22 Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
23 Cc: <stable@vger.kernel.org>
24 Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
25 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
26 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
30 1 file changed, 4 insertions(+), 2 deletions(-)
34 @@ -869,8 +869,10 @@ static struct alien_cache *__alloc_alien
35 struct alien_cache *alc = NULL;
37 alc = kmalloc_node(memsize, gfp, node);
38 - init_arraycache(&alc->ac, entries, batch);
39 - spin_lock_init(&alc->lock);
41 + init_arraycache(&alc->ac, entries, batch);
42 + spin_lock_init(&alc->lock);