[patch 1/1] selinux: fix memory leak
From: Stephen Smalley
Date: Tue Jul 25 2006 - 10:05:42 EST
From: Darrel Goeddel <dgoeddel@xxxxxxxxxxxxx>
This patch fixes a memory leak when a policydb structure
is destroyed. Please apply for 2.6.18.
Signed-off-by: Darrel Goeddel <dgoeddel@xxxxxxxxxxxxx>
Signed-off-by: Stephen Smalley <sds@xxxxxxxxxxxxx>
Acked-by: James Morris <jmorris@xxxxxxxxx>
---
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 majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/