/* Returns 0 if nothing goes wrong or -ENOMEM if it fails during the allocation of the new pair to add.  */
static int smk_set_access(struct smack_rule *srp)
/* Returns 0 if nothing goes wrong or -ENOMEM if it fails during the allocation of the new pair to add.  */
static int smk_set_access(struct smack_rule *srp)
{
	struct smack_rule *sp;
	int ret = 0;
	int found;
	mutex_lock(&smack_list_lock);
	found = 0;
	list_for_each_entry_rcu(sp, &smack_rule_list, list) {
		if (sp->smk_subject == srp->smk_subject &&
		    sp->smk_object == srp->smk_object) {
			found = 1;
			sp->smk_access = srp->smk_access;
			break;
		}
	}
	if (found == 0)
		list_add_rcu(&srp->list, &smack_rule_list);
	mutex_unlock(&smack_list_lock);
	return ret;
}