Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dfce8648 authored by Christoph Lameter's avatar Christoph Lameter Committed by Linus Torvalds
Browse files

SLUB: do proper locking during dma slab creation



We modify the kmalloc_cache_dma[] array without proper locking.  Do the proper
locking and undo the dma cache creation if another processor has already
created it.

Signed-off-by: default avatarChristoph Lameter <clameter@sgi.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 2e443fd0
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -2301,9 +2301,16 @@ static noinline struct kmem_cache *dma_kmalloc_cache(int index, gfp_t flags)
	text = kasprintf(flags & ~SLUB_DMA, "kmalloc_dma-%d",
			(unsigned int)realsize);
	s = create_kmalloc_cache(x, text, realsize, flags);
	down_write(&slub_lock);
	if (!kmalloc_caches_dma[index]) {
		kmalloc_caches_dma[index] = s;
		up_write(&slub_lock);
		return s;
	}
	up_write(&slub_lock);
	kmem_cache_destroy(s);
	return kmalloc_caches_dma[index];
}
#endif

static struct kmem_cache *get_slab(size_t size, gfp_t flags)