[patch 1/1] selinux: fix memory leak

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Darrel Goeddel <[email protected]>

This patch fixes a memory leak when a policydb structure
is destroyed.  Please apply for 2.6.18.

Signed-off-by: Darrel Goeddel <[email protected]>
Signed-off-by: Stephen Smalley <[email protected]>
Acked-by:  James Morris <[email protected]>

---

 security/selinux/ss/policydb.c |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff -X /home/sds/dontdiff -rup linux-2.6.18-rc2-git2/security/selinux/ss/policydb.c linux-2.6.18-rc2-git2-x/security/selinux/ss/policydb.c
--- linux-2.6.18-rc2-git2/security/selinux/ss/policydb.c	2006-06-17 21:49:35.000000000 -0400
+++ linux-2.6.18-rc2-git2-x/security/selinux/ss/policydb.c	2006-07-24 11:31:54.000000000 -0400
@@ -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++)

-- 
Stephen Smalley
National Security Agency

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux