Skip to content

Commit

Permalink
SLUB: do proper locking during dma slab creation
Browse files Browse the repository at this point in the history
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: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Christoph Lameter authored and Linus Torvalds committed Jul 17, 2007
1 parent 2e443fd commit dfce864
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions mm/slub.c
Original file line number Diff line number Diff line change
Expand Up @@ -2301,8 +2301,15 @@ 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);
kmalloc_caches_dma[index] = s;
return s;
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

Expand Down

0 comments on commit dfce864

Please sign in to comment.