From: Jesper Juhl Date: Fri, 20 Jul 2007 22:12:44 +0000 (+0200) Subject: SELinux: fix memory leak in security_netlbl_cache_add() X-Git-Tag: MMI-PSA29.97-13-9~41171^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=0ec8abd7086ee4f760cb1b477fe376805b17558c;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git SELinux: fix memory leak in security_netlbl_cache_add() Fix memory leak in security_netlbl_cache_add() Note: The Coverity checker gets credit for spotting this one. Signed-off-by: Jesper Juhl Signed-off-by: James Morris Acked-by: Stephen Smalley --- diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c index b5f017f07a75..0ae032f3876b 100644 --- a/security/selinux/ss/services.c +++ b/security/selinux/ss/services.c @@ -2417,8 +2417,10 @@ static void security_netlbl_cache_add(struct netlbl_lsm_secattr *secattr, cache->type = NETLBL_CACHE_T_MLS; if (ebitmap_cpy(&cache->data.mls_label.level[0].cat, - &ctx->range.level[0].cat) != 0) + &ctx->range.level[0].cat) != 0) { + kfree(cache); return; + } cache->data.mls_label.level[1].cat.highbit = cache->data.mls_label.level[0].cat.highbit; cache->data.mls_label.level[1].cat.node =