]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selinux: replace kmem_cache_create() with KMEM_CACHE()
authorEric Suen <ericsu@linux.microsoft.com>
Tue, 27 Aug 2024 17:40:03 +0000 (10:40 -0700)
committerPaul Moore <paul@paul-moore.com>
Tue, 27 Aug 2024 22:42:27 +0000 (18:42 -0400)
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 <ericsu@linux.microsoft.com>
[PM: minor grammar nits in the description]
Signed-off-by: Paul Moore <paul@paul-moore.com>
security/selinux/avc.c
security/selinux/ss/avtab.c
security/selinux/ss/ebitmap.c
security/selinux/ss/hashtab.c

index 32eb67fb3e42c0f0e88b70ee37bf9a3afcd8e7d4..1ec377ce6d226e86607e54b6aaf90f68472276e5 100644 (file)
@@ -134,18 +134,10 @@ static inline u32 avc_hash(u32 ssid, u32 tsid, u16 tclass)
  */
 void __init avc_init(void)
 {
-       avc_node_cachep = kmem_cache_create("avc_node", sizeof(struct avc_node),
-                                       0, SLAB_PANIC, NULL);
-       avc_xperms_cachep = kmem_cache_create("avc_xperms_node",
-                                       sizeof(struct avc_xperms_node),
-                                       0, SLAB_PANIC, NULL);
-       avc_xperms_decision_cachep = kmem_cache_create(
-                                       "avc_xperms_decision_node",
-                                       sizeof(struct avc_xperms_decision_node),
-                                       0, SLAB_PANIC, NULL);
-       avc_xperms_data_cachep = kmem_cache_create("avc_xperms_data",
-                                       sizeof(struct extended_perms_data),
-                                       0, SLAB_PANIC, NULL);
+       avc_node_cachep = KMEM_CACHE(avc_node, SLAB_PANIC);
+       avc_xperms_cachep = KMEM_CACHE(avc_xperms_node, SLAB_PANIC);
+       avc_xperms_decision_cachep = KMEM_CACHE(avc_xperms_decision_node, SLAB_PANIC);
+       avc_xperms_data_cachep = KMEM_CACHE(extended_perms_data, SLAB_PANIC);
 }
 
 int avc_get_hash_stats(char *page)
index 2ad98732d052c86bf4b19f0c9d947fe3fdd68831..8e400dd736b7a0a9ddb2054dc0046206d50a5068 100644 (file)
@@ -604,9 +604,6 @@ int avtab_write(struct policydb *p, struct avtab *a, void *fp)
 
 void __init avtab_cache_init(void)
 {
-       avtab_node_cachep = kmem_cache_create(
-               "avtab_node", sizeof(struct avtab_node), 0, SLAB_PANIC, NULL);
-       avtab_xperms_cachep = kmem_cache_create(
-               "avtab_extended_perms", sizeof(struct avtab_extended_perms), 0,
-               SLAB_PANIC, NULL);
+       avtab_node_cachep = KMEM_CACHE(avtab_node, SLAB_PANIC);
+       avtab_xperms_cachep = KMEM_CACHE(avtab_extended_perms, SLAB_PANIC);
 }
index 04d7f4907a0681a5f9fe445782d30b5101d8a92a..99c01be15115aa024a119dc9dbcc743d6da7da84 100644 (file)
@@ -572,7 +572,5 @@ u32 ebitmap_hash(const struct ebitmap *e, u32 hash)
 
 void __init ebitmap_cache_init(void)
 {
-       ebitmap_node_cachep = kmem_cache_create("ebitmap_node",
-                                               sizeof(struct ebitmap_node), 0,
-                                               SLAB_PANIC, NULL);
+       ebitmap_node_cachep = KMEM_CACHE(ebitmap_node, SLAB_PANIC);
 }
index 32c4cb37f3d2fd4fe7c25cb4d446aa4284eec9d7..383fd2d70878e52487dade8c0b4c58c93e74fb2d 100644 (file)
@@ -194,7 +194,5 @@ error:
 
 void __init hashtab_cache_init(void)
 {
-       hashtab_node_cachep = kmem_cache_create("hashtab_node",
-                                               sizeof(struct hashtab_node), 0,
-                                               SLAB_PANIC, NULL);
+       hashtab_node_cachep = KMEM_CACHE(hashtab_node, SLAB_PANIC);
 }