Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0dce2c3b authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "selinux: ensure we cleanup the internal AVC counters on error in avc_insert()"

parents 030cf3ec f6448d0a
Loading
Loading
Loading
Loading
+25 −27
Original line number Original line Diff line number Diff line
@@ -663,26 +663,25 @@ static struct avc_node *avc_insert(u32 ssid, u32 tsid, u16 tclass,
	struct avc_node *pos, *node = NULL;
	struct avc_node *pos, *node = NULL;
	int hvalue;
	int hvalue;
	unsigned long flag;
	unsigned long flag;
	spinlock_t *lock;
	struct hlist_head *head;


	if (avc_latest_notif_update(avd->seqno, 1))
	if (avc_latest_notif_update(avd->seqno, 1))
		goto out;
		return NULL;


	node = avc_alloc_node();
	node = avc_alloc_node();
	if (node) {
	if (!node)
		struct hlist_head *head;
		return NULL;
		spinlock_t *lock;
		int rc = 0;


		hvalue = avc_hash(ssid, tsid, tclass);
	avc_node_populate(node, ssid, tsid, tclass, avd);
	avc_node_populate(node, ssid, tsid, tclass, avd);
		rc = avc_xperms_populate(node, xp_node);
	if (avc_xperms_populate(node, xp_node)) {
		if (rc) {
		avc_node_kill(node);
			kmem_cache_free(avc_node_cachep, node);
		return NULL;
		return NULL;
	}
	}

	hvalue = avc_hash(ssid, tsid, tclass);
	head = &avc_cache.slots[hvalue];
	head = &avc_cache.slots[hvalue];
	lock = &avc_cache.slots_lock[hvalue];
	lock = &avc_cache.slots_lock[hvalue];

	spin_lock_irqsave(lock, flag);
	spin_lock_irqsave(lock, flag);
	hlist_for_each_entry(pos, head, list) {
	hlist_for_each_entry(pos, head, list) {
		if (pos->ae.ssid == ssid &&
		if (pos->ae.ssid == ssid &&
@@ -692,11 +691,10 @@ static struct avc_node *avc_insert(u32 ssid, u32 tsid, u16 tclass,
			goto found;
			goto found;
		}
		}
	}
	}

	hlist_add_head_rcu(&node->list, head);
	hlist_add_head_rcu(&node->list, head);
found:
found:
	spin_unlock_irqrestore(lock, flag);
	spin_unlock_irqrestore(lock, flag);
	}
out:
	return node;
	return node;
}
}