“kmem_cache_create: duplicate cache XXX”

In my kernel module, firstly I wrote:

In centos 7, this module works fine, but after port to centos 6, this kernel module reports:

The key to this problme is in the implementation of kmem_cache_create() in 2.6.32 linux kernel (for centos 6):

After creating a new pool, it only point to ‘name’, not strdup() a new one. But the ‘name’ in my kernel module is a temporary variable (in stack), so it considers the name is “duplicated”.
The correct code should like:

But why the old kernel module did not report error in centos 7? Because in centos 7 the default memory allocator is SLUB, and in centos 6 it is SLAB. They have totally different implementation.