summaryrefslogtreecommitdiffstats
path: root/security/tomoyo/realpath.c
diff options
context:
space:
mode:
authorTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>2010-05-06 12:40:02 +0900
committerJames Morris <jmorris@namei.org>2010-05-10 17:59:02 +1000
commit9e4b50e93786d00c703f16ed46e6a4029c0dfdd1 (patch)
tree51bf6072802888592ae98b9a6c8a26fcb2e1988f /security/tomoyo/realpath.c
parent83c36ccfe4d849f482ea0a62402c7624f4e59f0e (diff)
downloadlinux-9e4b50e93786d00c703f16ed46e6a4029c0dfdd1.tar.gz
linux-9e4b50e93786d00c703f16ed46e6a4029c0dfdd1.tar.bz2
linux-9e4b50e93786d00c703f16ed46e6a4029c0dfdd1.zip
TOMOYO: Use stack memory for pending entry.
Use stack memory for pending entry to reduce kmalloc() which will be kfree()d. Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'security/tomoyo/realpath.c')
-rw-r--r--security/tomoyo/realpath.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/security/tomoyo/realpath.c b/security/tomoyo/realpath.c
index 62062a68525a..d1b96f019621 100644
--- a/security/tomoyo/realpath.c
+++ b/security/tomoyo/realpath.c
@@ -223,6 +223,25 @@ bool tomoyo_memory_ok(void *ptr)
}
/**
+ * tomoyo_commit_ok - Check memory quota.
+ *
+ * @data: Data to copy from.
+ * @size: Size in byte.
+ *
+ * Returns pointer to allocated memory on success, NULL otherwise.
+ */
+void *tomoyo_commit_ok(void *data, const unsigned int size)
+{
+ void *ptr = kzalloc(size, GFP_NOFS);
+ if (tomoyo_memory_ok(ptr)) {
+ memmove(ptr, data, size);
+ memset(data, 0, size);
+ return ptr;
+ }
+ return NULL;
+}
+
+/**
* tomoyo_memory_free - Free memory for elements.
*
* @ptr: Pointer to allocated memory.