]> err.no Git - linux-2.6/commitdiff
SELinux: fix memory leak in security_netlbl_cache_add()
authorJesper Juhl <jesper.juhl@gmail.com>
Fri, 20 Jul 2007 22:12:44 +0000 (00:12 +0200)
committerJames Morris <jmorris@namei.org>
Mon, 23 Jul 2007 13:35:37 +0000 (09:35 -0400)
Fix memory leak in security_netlbl_cache_add()
Note: The Coverity checker gets credit for spotting this one.

Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
Signed-off-by: James Morris <jmorris@namei.org>
Acked-by: Stephen Smalley <sds@tycho.nsa.gov>
security/selinux/ss/services.c

index b5f017f07a75b6f614faf3cd9631fdc370936f0f..0ae032f3876b0717628f84c4df98c2e53c6e400a 100644 (file)
@@ -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 =