TOMOYO: Do not call tomoyo_realpath_init unless registered.

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>
diff --git a/security/tomoyo/realpath.c b/security/tomoyo/realpath.c
index 5fd48d2..d47f16b 100644
--- a/security/tomoyo/realpath.c
+++ b/security/tomoyo/realpath.c
@@ -371,10 +371,8 @@
 
 /**
  * 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 @@
 	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;
 
diff --git a/security/tomoyo/realpath.h b/security/tomoyo/realpath.h
index 0ea541f..7ec9fc9c 100644
--- a/security/tomoyo/realpath.h
+++ b/security/tomoyo/realpath.h
@@ -60,4 +60,7 @@
 /* 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) */
diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
index cc599b3..3eeeae1 100644
--- a/security/tomoyo/tomoyo.c
+++ b/security/tomoyo/tomoyo.c
@@ -287,6 +287,7 @@
 		panic("Failure registering TOMOYO Linux");
 	printk(KERN_INFO "TOMOYO Linux initialized\n");
 	cred->security = &tomoyo_kernel_domain;
+	tomoyo_realpath_init();
 	return 0;
 }