Let us not leak memory in SELinux : security_netlbl_cache_add()
PATCH 1/1 Let us not leak memory in SELinux : security_netlbl_cache_add()
Hi,
Leaking memory is a bad idea, so let's not do it, in security/selinux/ss/services.c::security_netlbl_cache_add().
Note: The Coverity checker gets credit for spotting this one.
Note: Patch has only been compile tested.
Signed-off-by Jesper Juhl <[email protected]>
---
security/selinux/ss/services.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
security/selinux/ss/services.c +3 -1
@@ -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 =
Quoted 7 lines · Jesper Juhl
Hi,
Leaking memory is a bad idea, so let's not do it, in security/selinux/ss/services.c::security_netlbl_cache_add().
Note: The Coverity checker gets credit for spotting this one.
Note: Patch has only been compile tested.
Thanks!
Verified and applied to:
git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/selinux-2.6.git#for-linus
- James
Signature · 2 lines
James Morris <[email protected]>