- bool result = false;
- if (!ptr || (tomoyo_quota_for_elements &&
- tomoyo_allocated_memory_for_elements
- + allocated_len > tomoyo_quota_for_elements)) {
- printk(KERN_WARNING "ERROR: Out of memory "
- "for tomoyo_alloc_element().\n");
- if (!tomoyo_policy_loaded)
- panic("MAC Initialization failed.\n");
- } else {
- result = true;
- tomoyo_allocated_memory_for_elements += allocated_len;
+ atomic_add(allocated_len, &tomoyo_policy_memory_size);
+ if (ptr && (!tomoyo_quota_for_policy ||
+ atomic_read(&tomoyo_policy_memory_size)
+ <= tomoyo_quota_for_policy)) {