]> git.ipfire.org Git - thirdparty/kernel/stable.git/blobdiff - security/smack/smack_lsm.c
Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux...
[thirdparty/kernel/stable.git] / security / smack / smack_lsm.c
index 433ae61e7f42e9a17a903a811abbf01f970cdbe8..f1b17a476e12d1f733ba877305b7615964a5f8af 100644 (file)
@@ -53,6 +53,7 @@
 #define SMK_SENDING    2
 
 LIST_HEAD(smk_ipv6_port_list);
+static struct kmem_cache *smack_inode_cache;
 
 #ifdef CONFIG_SECURITY_SMACK_BRINGUP
 static void smk_bu_mode(int mode, char *s)
@@ -240,7 +241,7 @@ struct inode_smack *new_inode_smack(struct smack_known *skp)
 {
        struct inode_smack *isp;
 
-       isp = kzalloc(sizeof(struct inode_smack), GFP_NOFS);
+       isp = kmem_cache_zalloc(smack_inode_cache, GFP_NOFS);
        if (isp == NULL)
                return NULL;
 
@@ -767,7 +768,7 @@ static int smack_inode_alloc_security(struct inode *inode)
  */
 static void smack_inode_free_security(struct inode *inode)
 {
-       kfree(inode->i_security);
+       kmem_cache_free(smack_inode_cache, inode->i_security);
        inode->i_security = NULL;
 }
 
@@ -4264,10 +4265,16 @@ static __init int smack_init(void)
        if (!security_module_enable(&smack_ops))
                return 0;
 
+       smack_inode_cache = KMEM_CACHE(inode_smack, 0);
+       if (!smack_inode_cache)
+               return -ENOMEM;
+
        tsp = new_task_smack(&smack_known_floor, &smack_known_floor,
                                GFP_KERNEL);
-       if (tsp == NULL)
+       if (tsp == NULL) {
+               kmem_cache_destroy(smack_inode_cache);
                return -ENOMEM;
+       }
 
        printk(KERN_INFO "Smack:  Initializing.\n");