Skip to content

Commit 4ad858b

Browse files
Eric Suenpcmoore
authored andcommitted
selinux: replace kmem_cache_create() with KMEM_CACHE()
Based on guidance in include/linux/slab.h, replace kmem_cache_create() with KMEM_CACHE() for sources under security/selinux to simplify creation of SLAB caches. Signed-off-by: Eric Suen <[email protected]> [PM: minor grammar nits in the description] Signed-off-by: Paul Moore <[email protected]>
1 parent 2571bb9 commit 4ad858b

File tree

4 files changed

+8
-23
lines changed

4 files changed

+8
-23
lines changed

security/selinux/avc.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -134,18 +134,10 @@ static inline u32 avc_hash(u32 ssid, u32 tsid, u16 tclass)
134134
*/
135135
void __init avc_init(void)
136136
{
137-
avc_node_cachep = kmem_cache_create("avc_node", sizeof(struct avc_node),
138-
0, SLAB_PANIC, NULL);
139-
avc_xperms_cachep = kmem_cache_create("avc_xperms_node",
140-
sizeof(struct avc_xperms_node),
141-
0, SLAB_PANIC, NULL);
142-
avc_xperms_decision_cachep = kmem_cache_create(
143-
"avc_xperms_decision_node",
144-
sizeof(struct avc_xperms_decision_node),
145-
0, SLAB_PANIC, NULL);
146-
avc_xperms_data_cachep = kmem_cache_create("avc_xperms_data",
147-
sizeof(struct extended_perms_data),
148-
0, SLAB_PANIC, NULL);
137+
avc_node_cachep = KMEM_CACHE(avc_node, SLAB_PANIC);
138+
avc_xperms_cachep = KMEM_CACHE(avc_xperms_node, SLAB_PANIC);
139+
avc_xperms_decision_cachep = KMEM_CACHE(avc_xperms_decision_node, SLAB_PANIC);
140+
avc_xperms_data_cachep = KMEM_CACHE(extended_perms_data, SLAB_PANIC);
149141
}
150142

151143
int avc_get_hash_stats(char *page)

security/selinux/ss/avtab.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -604,9 +604,6 @@ int avtab_write(struct policydb *p, struct avtab *a, void *fp)
604604

605605
void __init avtab_cache_init(void)
606606
{
607-
avtab_node_cachep = kmem_cache_create(
608-
"avtab_node", sizeof(struct avtab_node), 0, SLAB_PANIC, NULL);
609-
avtab_xperms_cachep = kmem_cache_create(
610-
"avtab_extended_perms", sizeof(struct avtab_extended_perms), 0,
611-
SLAB_PANIC, NULL);
607+
avtab_node_cachep = KMEM_CACHE(avtab_node, SLAB_PANIC);
608+
avtab_xperms_cachep = KMEM_CACHE(avtab_extended_perms, SLAB_PANIC);
612609
}

security/selinux/ss/ebitmap.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,5 @@ u32 ebitmap_hash(const struct ebitmap *e, u32 hash)
572572

573573
void __init ebitmap_cache_init(void)
574574
{
575-
ebitmap_node_cachep = kmem_cache_create("ebitmap_node",
576-
sizeof(struct ebitmap_node), 0,
577-
SLAB_PANIC, NULL);
575+
ebitmap_node_cachep = KMEM_CACHE(ebitmap_node, SLAB_PANIC);
578576
}

security/selinux/ss/hashtab.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,5 @@ int hashtab_duplicate(struct hashtab *new, const struct hashtab *orig,
194194

195195
void __init hashtab_cache_init(void)
196196
{
197-
hashtab_node_cachep = kmem_cache_create("hashtab_node",
198-
sizeof(struct hashtab_node), 0,
199-
SLAB_PANIC, NULL);
197+
hashtab_node_cachep = KMEM_CACHE(hashtab_node, SLAB_PANIC);
200198
}

0 commit comments

Comments
 (0)