/* Returns pointer to "struct tomoyo_profile" on success, NULL otherwise.  */
static struct tomoyo_profile* tomoyo_find_or_assign_new_profile(const unsigned int profile)
/* Returns pointer to "struct tomoyo_profile" on success, NULL otherwise.  */
static struct tomoyo_profile* tomoyo_find_or_assign_new_profile(const unsigned int profile)
{
	static DEFINE_MUTEX(lock);
	struct tomoyo_profile *ptr = NULL;
	int i;
	if (profile >= TOMOYO_MAX_PROFILES)
		return NULL;
	mutex_lock(&lock);
	ptr = tomoyo_profile_ptr[profile];
	if (ptr)
		goto ok;
	ptr = tomoyo_alloc_element(sizeof(*ptr));
	if (!ptr)
		goto ok;
	for (i = 0; i < TOMOYO_MAX_CONTROL_INDEX; i++)
		ptr->value[i] = tomoyo_control_array[i].current_value;
	mb();
	tomoyo_profile_ptr[profile] = ptr;
 ok:
	mutex_unlock(&lock);
	return ptr;
}