aboutsummaryrefslogtreecommitdiffstats
path: root/security/selinux/selinuxfs.c
diff options
context:
space:
mode:
authorJames Morris <jmorris@namei.org>2006-03-22 03:09:17 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-22 10:54:07 -0500
commit161ce45a8a34ba81673f60c603e6fc6d37d99c8f (patch)
tree7e3851140870164beb585f32a70e2dc81668f391 /security/selinux/selinuxfs.c
parentcde174a885821b5eee7e00c8a9a426c9c8186a29 (diff)
[PATCH] selinuxfs cleanups: sel_fill_super exit path
Unify 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). Signed-off-by: James Morris <jmorris@namei.org> Acked-by: Stephen Smalley <sds@tycho.nsa.gov> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'security/selinux/selinuxfs.c')
-rw-r--r--security/selinux/selinuxfs.c41
1 files changed, 24 insertions, 17 deletions
diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c
index f898080b9493..1bfb40701b5a 100644
--- a/security/selinux/selinuxfs.c
+++ b/security/selinux/selinuxfs.c
@@ -1213,28 +1213,34 @@ static int sel_fill_super(struct super_block * sb, void * data, int silent)
1213 }; 1213 };
1214 ret = simple_fill_super(sb, SELINUX_MAGIC, selinux_files); 1214 ret = simple_fill_super(sb, SELINUX_MAGIC, selinux_files);
1215 if (ret) 1215 if (ret)
1216 return ret; 1216 goto err;
1217 1217
1218 dentry = d_alloc_name(sb->s_root, BOOL_DIR_NAME); 1218 dentry = d_alloc_name(sb->s_root, BOOL_DIR_NAME);
1219 if (!dentry) 1219 if (!dentry) {
1220 return -ENOMEM; 1220 ret = -ENOMEM;
1221 goto err;
1222 }
1221 1223
1222 ret = sel_make_dir(sb, dentry); 1224 ret = sel_make_dir(sb, dentry);
1223 if (ret) 1225 if (ret)
1224 return ret; 1226 goto err;
1225 1227
1226 bool_dir = dentry; 1228 bool_dir = dentry;
1227 ret = sel_make_bools(); 1229 ret = sel_make_bools();
1228 if (ret) 1230 if (ret)
1229 goto out; 1231 goto err;
1230 1232
1231 dentry = d_alloc_name(sb->s_root, NULL_FILE_NAME); 1233 dentry = d_alloc_name(sb->s_root, NULL_FILE_NAME);
1232 if (!dentry) 1234 if (!dentry) {
1233 return -ENOMEM; 1235 ret = -ENOMEM;
1236 goto err;
1237 }
1234 1238
1235 inode = sel_make_inode(sb, S_IFCHR | S_IRUGO | S_IWUGO); 1239 inode = sel_make_inode(sb, S_IFCHR | S_IRUGO | S_IWUGO);
1236 if (!inode) 1240 if (!inode) {
1237 goto out; 1241 ret = -ENOMEM;
1242 goto err;
1243 }
1238 isec = (struct inode_security_struct*)inode->i_security; 1244 isec = (struct inode_security_struct*)inode->i_security;
1239 isec->sid = SECINITSID_DEVNULL; 1245 isec->sid = SECINITSID_DEVNULL;
1240 isec->sclass = SECCLASS_CHR_FILE; 1246 isec->sclass = SECCLASS_CHR_FILE;
@@ -1245,22 +1251,23 @@ static int sel_fill_super(struct super_block * sb, void * data, int silent)
1245 selinux_null = dentry; 1251 selinux_null = dentry;
1246 1252
1247 dentry = d_alloc_name(sb->s_root, "avc"); 1253 dentry = d_alloc_name(sb->s_root, "avc");
1248 if (!dentry) 1254 if (!dentry) {
1249 return -ENOMEM; 1255 ret = -ENOMEM;
1256 goto err;
1257 }
1250 1258
1251 ret = sel_make_dir(sb, dentry); 1259 ret = sel_make_dir(sb, dentry);
1252 if (ret) 1260 if (ret)
1253 goto out; 1261 goto err;
1254 1262
1255 ret = sel_make_avc_files(dentry); 1263 ret = sel_make_avc_files(dentry);
1256 if (ret) 1264 if (ret)
1257 goto out; 1265 goto err;
1258
1259 return 0;
1260out: 1266out:
1261 dput(dentry); 1267 return ret;
1268err:
1262 printk(KERN_ERR "%s: failed while creating inodes\n", __FUNCTION__); 1269 printk(KERN_ERR "%s: failed while creating inodes\n", __FUNCTION__);
1263 return -ENOMEM; 1270 goto out;
1264} 1271}
1265 1272
1266static struct super_block *sel_get_sb(struct file_system_type *fs_type, 1273static struct super_block *sel_get_sb(struct file_system_type *fs_type,