mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH][SELinux] Let us not leak memory in SELinux : security_netlbl_cache_add()
@ 2007-07-20 22:12 Jesper Juhl
  2007-07-20 23:39 ` James Morris
  0 siblings, 1 reply; 2+ messages in thread
From: Jesper Juhl @ 2007-07-20 22:12 UTC (permalink / raw)
  To: Linux Kernel Mailing List
  Cc: Stephen Smalley, James Morris, dgoeddel, Frank Mayer,
	Karl MacMillan, paul.moore, Chad Sellers, Stephen Smalley,
	James Morris, Eric Paris, 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.


Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---

 security/selinux/ss/services.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c
index b5f017f..0ae032f 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 =



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH][SELinux] Let us not leak memory in SELinux : security_netlbl_cache_add()
  2007-07-20 22:12 [PATCH][SELinux] Let us not leak memory in SELinux : security_netlbl_cache_add() Jesper Juhl
@ 2007-07-20 23:39 ` James Morris
  0 siblings, 0 replies; 2+ messages in thread
From: James Morris @ 2007-07-20 23:39 UTC (permalink / raw)
  To: Jesper Juhl
  Cc: Linux Kernel Mailing List, Stephen Smalley, James Morris,
	dgoeddel, Frank Mayer, Karl MacMillan, paul.moore, Chad Sellers,
	Stephen Smalley, Eric Paris

On Sat, 21 Jul 2007, Jesper Juhl wrote:

> 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
-- 
James Morris
<jmorris@namei.org>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-07-20 23:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-20 22:12 [PATCH][SELinux] Let us not leak memory in SELinux : security_netlbl_cache_add() Jesper Juhl
2007-07-20 23:39 ` James Morris

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®