TOMOYO: Use stack memory for pending entry.
[pandora-kernel.git] / security / tomoyo / realpath.c
index 62062a6..d1b96f0 100644 (file)
@@ -222,6 +222,25 @@ bool tomoyo_memory_ok(void *ptr)
        return false;
 }
 
+/**
+ * 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.
  *