mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jesper Juhl <jesper.juhl@gmail.com>
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Cc: Stephen Smalley <sds@epoch.ncsc.mil>,
	James Morris <jmorris@redhat.com>,
	dgoeddel@trustedcs.com, Frank Mayer <mayerf@tresys.com>,
	Karl MacMillan <kmacmillan@tresys.com>,
	paul.moore@hp.com, Chad Sellers <csellers@tresys.com>,
	Stephen Smalley <sds@tycho.nsa.gov>,
	James Morris <jmorris@namei.org>,
	Eric Paris <eparis@parisplace.org>,
	Jesper Juhl <jesper.juhl@gmail.com>
Subject: [PATCH][SELinux] Let us not leak memory in SELinux : security_netlbl_cache_add()
Date: Sat, 21 Jul 2007 00:12:44 +0200	[thread overview]
Message-ID: <200707210012.45185.jesper.juhl@gmail.com> (raw)

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 =



             reply	other threads:[~2007-07-20 22:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-20 22:12 Jesper Juhl [this message]
2007-07-20 23:39 ` James Morris

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200707210012.45185.jesper.juhl@gmail.com \
    --to=jesper.juhl@gmail.com \
    --cc=csellers@tresys.com \
    --cc=dgoeddel@trustedcs.com \
    --cc=eparis@parisplace.org \
    --cc=jmorris@namei.org \
    --cc=jmorris@redhat.com \
    --cc=kmacmillan@tresys.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mayerf@tresys.com \
    --cc=paul.moore@hp.com \
    --cc=sds@epoch.ncsc.mil \
    --cc=sds@tycho.nsa.gov \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®