mm, mempool: disallow mempools based on slab caches with constructors
[firefly-linux-kernel-4.4.55.git] / mm / mempool.c
index 949970db28741532172ad2c7a65fdeb71c3f7404..b60fb85526ed62937e4545262b2cbb0b9894315f 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/mempool.h>
 #include <linux/blkdev.h>
 #include <linux/writeback.h>
+#include "slab.h"
 
 static void add_element(mempool_t *pool, void *element)
 {
@@ -334,6 +335,7 @@ EXPORT_SYMBOL(mempool_free);
 void *mempool_alloc_slab(gfp_t gfp_mask, void *pool_data)
 {
        struct kmem_cache *mem = pool_data;
+       VM_BUG_ON(mem->ctor);
        return kmem_cache_alloc(mem, gfp_mask);
 }
 EXPORT_SYMBOL(mempool_alloc_slab);