From cfeff00490d9b29aa802a0651a1c53fd0ba0771e Mon Sep 17 00:00:00 2001 From: Andrew Morton <akpm@osdl.org> Date: Wed, 19 May 2004 02:37:59 -0700 Subject: [PATCH] [PATCH] SELinux: fix error handling in selinuxfs 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. --- security/selinux/selinuxfs.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c index 1a589da54f1b..274275a61f4d 100644 --- a/security/selinux/selinuxfs.c +++ b/security/selinux/selinuxfs.c @@ -833,8 +833,10 @@ static ssize_t sel_write_bool(struct file *filep, const char *buf, 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(struct file *filep, const char *buf, goto out; } page = (char*)__get_free_page(GFP_KERNEL); - if (!page) - return -ENOMEM; + if (!page) { + length = -ENOMEM; + goto out; + } memset(page, 0, PAGE_SIZE); -- 2.30.9