Skip to contentSkip to conversation

selinux: fix memory leak

PATCH In review Darrel Goeddel 2 participants 2 messages Jul 13, 2006 – Jul 14, 2006 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selinux: fix memory leak

This patch fixes a possible memory leak when a policydb structure is destroyed.

security/selinux/ss/policydb.c +0 -0
index 0111990..f03960e 100644
@@ -644,10 +644,18 @@ void policydb_destroy(struct policydb *p
	kfree(lra);

	for (rt = p->range_tr; rt; rt = rt -> next) {

- kfree(lrt);
+ if (lrt) {
+ ebitmap_destroy(&lrt->range.level[0].cat);
+ ebitmap_destroy(&lrt->range.level[1].cat);
+ kfree(lrt);
+ }

		lrt = rt;
	}

- kfree(lrt);
+ if (lrt) {
+ ebitmap_destroy(&lrt->range.level[0].cat);
+ ebitmap_destroy(&lrt->range.level[1].cat);
+ kfree(lrt);
+ }

	if (p->type_attr_map) {
		for (i = 0; i < p->p_types.nprim; i++)

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Darrel Goeddel

This patch fixes a possible memory leak when a policydb structure is destroyed.

Quoted 27 lines
security/selinux/ss/policydb.c +10 -2
index 0111990..f03960e 100644
@@ -644,10 +644,18 @@ void policydb_destroy(struct policydb *p
 	kfree(lra);
 
 	for (rt = p->range_tr; rt; rt = rt -> next) {
-		kfree(lrt);
+		if (lrt) {
+			ebitmap_destroy(&lrt->range.level[0].cat);
+			ebitmap_destroy(&lrt->range.level[1].cat);
+			kfree(lrt);
+		}
 		lrt = rt;
 	}
-	kfree(lrt);
+	if (lrt) {
+		ebitmap_destroy(&lrt->range.level[0].cat);
+		ebitmap_destroy(&lrt->range.level[1].cat);
+		kfree(lrt);
+	}
 
 	if (p->type_attr_map) {
 		for (i = 0; i < p->p_types.nprim; i++)
Signature · 7 lines
James Morris
<[email protected]>

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.