All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel J Walsh <dwalsh@redhat.com>
To: SELinux <selinux@tycho.nsa.gov>
Subject: Fix memory leak on disabled selinux machines.
Date: Wed, 24 Feb 2010 14:15:31 -0500	[thread overview]
Message-ID: <4B857AD3.4090701@redhat.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 151 bytes --]

I think this patch originally came from Eric Paris and was updated by 
others but has not been adopted yet.  Not sure why.

Always free buf on exit.



[-- Attachment #2: libselinux_init.patch --]
[-- Type: text/plain, Size: 775 bytes --]

--- nsalibselinux/src/init.c	2009-07-14 11:16:03.000000000 -0400
+++ libselinux-2.0.90/src/init.c	2010-02-22 11:04:16.000000000 -0500
@@ -23,7 +23,7 @@
 static void init_selinuxmnt(void)
 {
 	char *buf=NULL, *p;
-	FILE *fp;
+	FILE *fp=NULL;
 	struct statfs sfbuf;
 	int rc;
 	size_t len;
@@ -57,16 +57,17 @@
 			break;
 		}
 	}
-	fclose(fp);
 
-	if (!exists)
-		return;
+	if (!exists) 
+		goto out;
+
+	fclose(fp);
 
 	/* At this point, the usual spot doesn't have an selinuxfs so
 	 * we look around for it */
 	fp = fopen("/proc/mounts", "r");
 	if (!fp)
-		return;
+		goto out;
 
 	__fsetlocking(fp, FSETLOCKING_BYCALLER);
 	while ((num = getline(&buf, &len, fp)) != -1) {
@@ -90,7 +91,8 @@
 
       out:
 	free(buf);
-	fclose(fp);
+	if (fp)
+		fclose(fp);
 	return;
 }
 

             reply	other threads:[~2010-02-24 19:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-24 19:15 Daniel J Walsh [this message]
2010-02-26  1:45 ` Fix memory leak on disabled selinux machines Joshua Brindle
2010-03-06 23:13   ` Joshua Brindle

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=4B857AD3.4090701@redhat.com \
    --to=dwalsh@redhat.com \
    --cc=selinux@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.