From: "Luiz Fernando N. Capitulino" <lcapitulino@prefeitura.sp.gov.br>
To: kernel-janitors@vger.kernel.org
Subject: [Kernel-janitors] [PATCH] - fs/namespace.c::copy_namespace()
Date: Mon, 17 May 2004 23:23:35 +0000 [thread overview]
Message-ID: <20040517232335.GD6248@lorien.prodam> (raw)
[-- 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
next reply other threads:[~2004-05-17 23:23 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-05-17 23:23 Luiz Fernando N. Capitulino [this message]
2004-05-18 0:03 ` [Kernel-janitors] [PATCH] - fs/namespace.c::copy_namespace() 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
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=20040517232335.GD6248@lorien.prodam \
--to=lcapitulino@prefeitura.sp.gov.br \
--cc=kernel-janitors@vger.kernel.org \
/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 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.