File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -88,13 +88,30 @@ unsigned int kmem_cache_size(struct kmem_cache *s)
88
88
EXPORT_SYMBOL (kmem_cache_size );
89
89
90
90
#ifdef CONFIG_DEBUG_VM
91
+
92
+ static bool kmem_cache_is_duplicate_name (const char * name )
93
+ {
94
+ struct kmem_cache * s ;
95
+
96
+ list_for_each_entry (s , & slab_caches , list ) {
97
+ if (!strcmp (s -> name , name ))
98
+ return true;
99
+ }
100
+
101
+ return false;
102
+ }
103
+
91
104
static int kmem_cache_sanity_check (const char * name , unsigned int size )
92
105
{
93
106
if (!name || in_interrupt () || size > KMALLOC_MAX_SIZE ) {
94
107
pr_err ("kmem_cache_create(%s) integrity check failed\n" , name );
95
108
return - EINVAL ;
96
109
}
97
110
111
+ /* Duplicate names will confuse slabtop, et al */
112
+ WARN (kmem_cache_is_duplicate_name (name ),
113
+ "kmem_cache of name '%s' already exists\n" , name );
114
+
98
115
WARN_ON (strchr (name , ' ' )); /* It confuses parsers */
99
116
return 0 ;
100
117
}
You can’t perform that action at this time.
0 commit comments