mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: James Morris <jmorris@namei.org>
To: Andrew Morton <akpm@osdl.org>
Cc: Stephen Smalley <sds@tycho.nsa.gov>, linux-kernel@vger.kernel.org
Subject: [PATCH 3/5] selinuxfs cleanups - sel_fill_super exit path
Date: Wed, 22 Feb 2006 09:54:21 -0500 (EST)	[thread overview]
Message-ID: <Pine.LNX.4.64.0602220952500.30349@excalibur.intercode> (raw)
In-Reply-To: <Pine.LNX.4.64.0602220948530.30349@excalibur.intercode>

This patch unifies the error path of sel_fill_super() so that all errors 
pass through the same point and generate an error message.  Also, removes 
a spurious dput() in the error path which breaks the refcounting for the 
filesystem (litter_kill_super() will correctly clean things up itself on 
error).

Please apply.


Signed-off-by: James Morris <jmorris@namei.org>
Acked-by: Stephen Smalley <sds@tycho.nsa.gov>

---

 selinuxfs.c |   41 ++++++++++++++++++++++++-----------------
 1 file changed, 24 insertions(+), 17 deletions(-)


diff -purN -X dontdiff linux-2.6.16-rc4.p/security/selinux/selinuxfs.c linux-2.6.16-rc4.w/security/selinux/selinuxfs.c
--- linux-2.6.16-rc4.p/security/selinux/selinuxfs.c	2006-02-21 16:32:54.000000000 -0500
+++ linux-2.6.16-rc4.w/security/selinux/selinuxfs.c	2006-02-21 19:56:04.000000000 -0500
@@ -1230,28 +1230,34 @@ static int sel_fill_super(struct super_b
 	};
 	ret = simple_fill_super(sb, SELINUX_MAGIC, selinux_files);
 	if (ret)
-		return ret;
+		goto err;
 
 	dentry = d_alloc_name(sb->s_root, BOOL_DIR_NAME);
-	if (!dentry)
-		return -ENOMEM;
+	if (!dentry) {
+		ret = -ENOMEM;
+		goto err;
+	}
 	
 	ret = sel_make_dir(sb, dentry);
 	if (ret)
-		return ret;
+		goto err;
 
 	bool_dir = dentry;
 	ret = sel_make_bools();
 	if (ret)
-		goto out;
+		goto err;
 
 	dentry = d_alloc_name(sb->s_root, NULL_FILE_NAME);
-	if (!dentry)
-		return -ENOMEM;
+	if (!dentry) {
+		ret = -ENOMEM;
+		goto err;
+	}
 
 	inode = sel_make_inode(sb, S_IFCHR | S_IRUGO | S_IWUGO);
-	if (!inode)
-		goto out;
+	if (!inode) {
+		ret = -ENOMEM;
+		goto err;
+	}
 	isec = (struct inode_security_struct*)inode->i_security;
 	isec->sid = SECINITSID_DEVNULL;
 	isec->sclass = SECCLASS_CHR_FILE;
@@ -1262,22 +1268,23 @@ static int sel_fill_super(struct super_b
 	selinux_null = dentry;
 
 	dentry = d_alloc_name(sb->s_root, "avc");
-	if (!dentry)
-		return -ENOMEM;
+	if (!dentry) {
+		ret = -ENOMEM;
+		goto err;
+	}
 
 	ret = sel_make_dir(sb, dentry);
 	if (ret)
-		goto out;
+		goto err;
 
 	ret = sel_make_avc_files(dentry);
 	if (ret)
-		goto out;
-
-	return 0;
+		goto err;
 out:
-	dput(dentry);
+	return ret;
+err:
 	printk(KERN_ERR "%s:  failed while creating inodes\n", __FUNCTION__);
-	return -ENOMEM;
+	goto out;
 }
 
 static struct super_block *sel_get_sb(struct file_system_type *fs_type,

  parent reply	other threads:[~2006-02-22 14:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-22 14:51 [PATCH 1/5] selinuxfs cleanups - fix hard link count James Morris
2006-02-22 14:52 ` [PATCH 2/5] selinuxfs cleanups - use sel_make_dir() James Morris
2006-02-22 14:54 ` James Morris [this message]
2006-02-22 14:55 ` [PATCH 4/5] selinuxfs cleanups - sel_make_bools James Morris
2006-02-22 14:56 ` [PATCH 5/5] selinuxfs cleanups - sel_make_avc_files 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=Pine.LNX.4.64.0602220952500.30349@excalibur.intercode \
    --to=jmorris@namei.org \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --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®