From: Stephen Smalley <sds@epoch.ncsc.mil>

This patch against 2.6.6 fixes error handling for two out-of-memory conditions
in selinuxfs, avoiding potential deadlock due to returning without releasing a
semaphore.  The patch was submitted by Karl MacMillan of Tresys.


---

 25-akpm/security/selinux/selinuxfs.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff -puN security/selinux/selinuxfs.c~fix-error-handling-in-selinuxfs security/selinux/selinuxfs.c
--- 25/security/selinux/selinuxfs.c~fix-error-handling-in-selinuxfs	Mon May 17 13:42:57 2004
+++ 25-akpm/security/selinux/selinuxfs.c	Mon May 17 13:42:57 2004
@@ -833,8 +833,10 @@ static ssize_t sel_write_bool(struct fil
 		goto out;
 	}
 	page = (char*)__get_free_page(GFP_KERNEL);
-	if (!page)
-		return -ENOMEM;
+	if (!page) {
+		length = -ENOMEM;
+		goto out;
+	}
 	memset(page, 0, PAGE_SIZE);
 
 	if (copy_from_user(page, buf, count))
@@ -889,8 +891,10 @@ static ssize_t sel_commit_bools_write(st
 		goto out;
 	}
 	page = (char*)__get_free_page(GFP_KERNEL);
-	if (!page)
-		return -ENOMEM;
+	if (!page) {
+		length = -ENOMEM;
+		goto out;
+	}
 
 	memset(page, 0, PAGE_SIZE);
 

_