All of lore.kernel.org
 help / color / mirror / Atom feed
* [Kernel-janitors] [PATCH] - fs/namespace.c::copy_namespace()
@ 2004-05-17 23:23 Luiz Fernando N. Capitulino
  2004-05-18  0:03 ` Michael Still
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Luiz Fernando N. Capitulino @ 2004-05-17 23:23 UTC (permalink / raw)
  To: kernel-janitors

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


 Hi!

 This patch is a little clean up, maybe it is the kind of
thing which Randy could say: "is better work on important
things". But it is impossible to read this code without
patch it. :-)

 put_namespace() is called four in different places, and the
goto is a little useless in that context. This patch puts the
things toghether.

 fs/namespace.c |   19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)


diff -X dontdiff -Nparu a/fs/namespace.c a~/fs/namespace.c
--- a/fs/namespace.c	2004-05-10 13:36:46.000000000 -0300
+++ a~/fs/namespace.c	2004-05-12 16:13:22.000000000 -0300
@@ -868,23 +868,26 @@ int copy_namespace(int flags, struct tas
 	struct namespace *new_ns;
 	struct vfsmount *rootmnt = NULL, *pwdmnt = NULL, *altrootmnt = NULL;
 	struct fs_struct *fs = tsk->fs;
+	int rc = 0;
 
 	if (!namespace)
-		return 0;
+		return rc;
 
 	get_namespace(namespace);
 
 	if (!(flags & CLONE_NEWNS))
-		return 0;
+		return rc;
 
 	if (!capable(CAP_SYS_ADMIN)) {
-		put_namespace(namespace);
-		return -EPERM;
+		rc = -EPERM;
+		goto out;
 	}
 
 	new_ns = kmalloc(sizeof(struct namespace), GFP_KERNEL);
-	if (!new_ns)
+	if (!new_ns) {
+		rc = -ENOMEM;
 		goto out;
+	}
 
 	atomic_set(&new_ns->count, 1);
 	init_rwsem(&new_ns->sem);
@@ -896,6 +899,7 @@ int copy_namespace(int flags, struct tas
 	if (!new_ns->root) {
 		up_write(&tsk->namespace->sem);
 		kfree(new_ns);
+		rc = -ENOMEM;
 		goto out;
 	}
 	spin_lock(&vfsmount_lock);
@@ -938,12 +942,9 @@ int copy_namespace(int flags, struct tas
 	if (altrootmnt)
 		mntput(altrootmnt);
 
-	put_namespace(namespace);
-	return 0;
-
 out:
 	put_namespace(namespace);
-	return -ENOMEM;
+	return rc;
 }
 
 asmlinkage long sys_mount(char __user * dev_name, char __user * dir_name,
-- 
Luiz Fernando N. Capitulino
<http://www.telecentros.sp.gov.br>

[-- Attachment #2: Type: text/plain, Size: 167 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-05-18 16:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-05-17 23:23 [Kernel-janitors] [PATCH] - fs/namespace.c::copy_namespace() Luiz Fernando N. Capitulino
2004-05-18  0:03 ` Michael Still
2004-05-18 13:03 ` Matthew Wilcox
2004-05-18 15:55 ` Re: [Kernel-janitors] [PATCH] - fs/namespace.c::copy_namesp Matthew Wilcox
2004-05-18 16:24 ` [Kernel-janitors] [PATCH] - fs/namespace.c::copy_namespace() Luiz Fernando N. Capitulino

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.