From: Darrel Goeddel Date: Sun, 30 Jul 2006 10:03:17 +0000 (-0700) Subject: [PATCH] selinux: fix memory leak X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ddccef3b5ec906ff181171e8ffad4fcb996792fd;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git [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 --- 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++)