TOMOYO: Do not call tomoyo_realpath_init unless registered.
authorTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Sat, 21 Feb 2009 11:40:50 +0000 (20:40 +0900)
committerJames Morris <jmorris@namei.org>
Sun, 22 Feb 2009 22:45:05 +0000 (09:45 +1100)
tomoyo_realpath_init() is unconditionally called by security_initcall().
But nobody will use realpath related functions if TOMOYO is not registered.

So, let tomoyo_init() call tomoyo_realpath_init().

This patch saves 4KB of memory allocation if TOMOYO is not registered.

Signed-off-by: Kentaro Takeda <takedakn@nttdata.co.jp>
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: Toshiharu Harada <haradats@nttdata.co.jp>
Signed-off-by: James Morris <jmorris@namei.org>
security/tomoyo/realpath.c
security/tomoyo/realpath.h
security/tomoyo/tomoyo.c

index 5fd48d23a2177c05658045a504503acd14ebbc0f..d47f16b844b2300090e02d8f017d2213610f4d33 100644 (file)
@@ -371,10 +371,8 @@ const struct tomoyo_path_info *tomoyo_save_name(const char *name)
 
 /**
  * tomoyo_realpath_init - Initialize realpath related code.
- *
- * Returns 0.
  */
-static int __init tomoyo_realpath_init(void)
+void __init tomoyo_realpath_init(void)
 {
        int i;
 
@@ -388,11 +386,8 @@ static int __init tomoyo_realpath_init(void)
        if (tomoyo_find_domain(TOMOYO_ROOT_NAME) != &tomoyo_kernel_domain)
                panic("Can't register tomoyo_kernel_domain");
        up_read(&tomoyo_domain_list_lock);
-       return 0;
 }
 
-security_initcall(tomoyo_realpath_init);
-
 /* Memory allocated for temporary purpose. */
 static atomic_t tomoyo_dynamic_memory_size;
 
index 0ea541fcb53cff21e017056c7b471ecb471923cf..7ec9fc9cbc071f9f7d7d89264e84ee0ac916da3a 100644 (file)
@@ -60,4 +60,7 @@ int tomoyo_read_memory_counter(struct tomoyo_io_buffer *head);
 /* Set memory quota. */
 int tomoyo_write_memory_quota(struct tomoyo_io_buffer *head);
 
+/* Initialize realpath related code. */
+void __init tomoyo_realpath_init(void);
+
 #endif /* !defined(_SECURITY_TOMOYO_REALPATH_H) */
index cc599b36a3a82ef16e749532ba9d6ed65cd93965..3eeeae12c4dcde1569e9b809bc97aa6dbf07d464 100644 (file)
@@ -287,6 +287,7 @@ static int __init tomoyo_init(void)
                panic("Failure registering TOMOYO Linux");
        printk(KERN_INFO "TOMOYO Linux initialized\n");
        cred->security = &tomoyo_kernel_domain;
+       tomoyo_realpath_init();
        return 0;
 }