Merge branch 'next' into for-linus
[safe/jmp/linux-2.6] / security / integrity / ima / ima_iint.c
index fa592ff..2dc2d65 100644 (file)
@@ -14,6 +14,7 @@
  *     - cache integrity information associated with an inode
  *       using a radix tree.
  */
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/spinlock.h>
 #include <linux/radix-tree.h>
@@ -52,9 +53,6 @@ int ima_inode_alloc(struct inode *inode)
        struct ima_iint_cache *iint = NULL;
        int rc = 0;
 
-       if (!ima_initialized)
-               return 0;
-
        iint = kmem_cache_alloc(iint_cache, GFP_NOFS);
        if (!iint)
                return -ENOMEM;
@@ -66,12 +64,11 @@ int ima_inode_alloc(struct inode *inode)
        spin_lock(&ima_iint_lock);
        rc = radix_tree_insert(&ima_iint_store, (unsigned long)inode, iint);
        spin_unlock(&ima_iint_lock);
+       radix_tree_preload_end();
 out:
        if (rc < 0)
                kmem_cache_free(iint_cache, iint);
 
-       radix_tree_preload_end();
-
        return rc;
 }
 
@@ -83,17 +80,17 @@ void iint_free(struct kref *kref)
        iint->version = 0;
        iint->flags = 0UL;
        if (iint->readcount != 0) {
-               printk(KERN_INFO "%s: readcount: %ld\n", __FUNCTION__,
+               printk(KERN_INFO "%s: readcount: %ld\n", __func__,
                       iint->readcount);
                iint->readcount = 0;
        }
        if (iint->writecount != 0) {
-               printk(KERN_INFO "%s: writecount: %ld\n", __FUNCTION__,
+               printk(KERN_INFO "%s: writecount: %ld\n", __func__,
                       iint->writecount);
                iint->writecount = 0;
        }
        if (iint->opencount != 0) {
-               printk(KERN_INFO "%s: opencount: %ld\n", __FUNCTION__,
+               printk(KERN_INFO "%s: opencount: %ld\n", __func__,
                       iint->opencount);
                iint->opencount = 0;
        }
@@ -118,8 +115,6 @@ void ima_inode_free(struct inode *inode)
 {
        struct ima_iint_cache *iint;
 
-       if (!ima_initialized)
-               return;
        spin_lock(&ima_iint_lock);
        iint = radix_tree_delete(&ima_iint_store, (unsigned long)inode);
        spin_unlock(&ima_iint_lock);
@@ -141,9 +136,11 @@ static void init_once(void *foo)
        kref_set(&iint->refcount, 1);
 }
 
-void __init ima_iintcache_init(void)
+static int __init ima_iintcache_init(void)
 {
        iint_cache =
            kmem_cache_create("iint_cache", sizeof(struct ima_iint_cache), 0,
                              SLAB_PANIC, init_once);
+       return 0;
 }
+security_initcall(ima_iintcache_init);