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 <[EMAIL PROTECTED]>

---
 mm/slub.c |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Index: linux-2.6.22-rc4-mm2/mm/slub.c
===================================================================
--- linux-2.6.22-rc4-mm2.orig/mm/slub.c 2007-06-17 18:12:10.000000000 -0700
+++ linux-2.6.22-rc4-mm2/mm/slub.c      2007-06-17 18:12:13.000000000 -0700
@@ -2310,8 +2310,15 @@ static struct kmem_cache *dma_kmalloc_ca
        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
 

-- 
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to