From ddccef3b5ec906ff181171e8ffad4fcb996792fd Mon Sep 17 00:00:00 2001 From: Darrel Goeddel Date: Sun, 30 Jul 2006 03:03:17 -0700 Subject: [PATCH] [PATCH] selinux: fix memory leak This patch fixes a memory leak when a policydb structure is destroyed. Signed-off-by: Darrel Goeddel Signed-off-by: Stephen Smalley Acked-by: James Morris Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- security/selinux/ss/policydb.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c index 0111990ba837..f03960e697ce 100644 --- a/security/selinux/ss/policydb.c +++ b/security/selinux/ss/policydb.c @@ -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++) -- 2.20.1