From: Li Zefan <lizf@cn.fujitsu.com>
To: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: Al Viro <viro@ZenIV.linux.org.uk>,
Andrew Morton <akpm@linux-foundation.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] vfs: use kstrdup()
Date: Mon, 21 Jul 2008 16:28:17 +0800 [thread overview]
Message-ID: <488448A1.3030608@cn.fujitsu.com> (raw)
In-Reply-To: <20080721080427.GC6662@lenovo>
Cyrill Gorcunov wrote:
> [Al Viro - Mon, Jul 21, 2008 at 08:03:46AM +0100]
> |
> [...]
> | The right thing here is to consider failing allocation of ->mnt_devname
> | as failure of the entire alloc.
> |
>
> Al, what about the patch below? I'm not sure if Li's version already
> in someone tree so it's from-the-scratch. If this ok, i think Li could
> update his version and resend.
>
It's already in -mm tree, but Andrew can drop it and queue the new one.
> - Cyrill -
> ---
>
> Index: linux-2.6.git/fs/namespace.c
> ===================================================================
> --- linux-2.6.git.orig/fs/namespace.c 2008-07-21 11:34:37.000000000 +0400
> +++ linux-2.6.git/fs/namespace.c 2008-07-21 12:00:01.000000000 +0400
> @@ -112,9 +112,13 @@ struct vfsmount *alloc_vfsmnt(const char
> int err;
>
> err = mnt_alloc_id(mnt);
> - if (err) {
> - kmem_cache_free(mnt_cache, mnt);
> - return NULL;
> + if (err)
> + goto err;
> +
> + if (name) {
> + mnt->mnt_devname = kstrdup(name, GFP_KERNEL);
> + if (!mnt->mnt_devname)
should call mnt_free_id() here.
> + goto err;
> }
>
> atomic_set(&mnt->mnt_count, 1);
> @@ -127,16 +131,12 @@ struct vfsmount *alloc_vfsmnt(const char
> INIT_LIST_HEAD(&mnt->mnt_slave_list);
> INIT_LIST_HEAD(&mnt->mnt_slave);
> atomic_set(&mnt->__mnt_writers, 0);
> - if (name) {
> - int size = strlen(name) + 1;
> - char *newname = kmalloc(size, GFP_KERNEL);
> - if (newname) {
> - memcpy(newname, name, size);
> - mnt->mnt_devname = newname;
> - }
> - }
> }
> return mnt;
> +
> +err:
> + kmem_cache_free(mnt_cache, mnt);
> + return NULL;
> }
>
> /*
>
>
next prev parent reply other threads:[~2008-07-21 8:30 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-19 10:16 [PATCH] vfs: use kstrdup() Li Zefan
2008-07-19 11:30 ` Pekka Enberg
2008-07-19 13:13 ` Cyrill Gorcunov
2008-07-19 13:19 ` Cyrill Gorcunov
2008-07-21 5:27 ` Al Viro
2008-07-21 6:29 ` Li Zefan
2008-07-21 7:03 ` Al Viro
2008-07-21 7:09 ` Cyrill Gorcunov
2008-07-21 8:04 ` Cyrill Gorcunov
2008-07-21 8:28 ` Li Zefan [this message]
2008-07-21 8:44 ` Cyrill Gorcunov
2008-07-21 8:59 ` Li Zefan
2008-07-21 9:06 ` Pekka Enberg
2008-07-21 10:05 ` Cyrill Gorcunov
2008-07-21 10:10 ` Li Zefan
2008-07-21 10:17 ` Cyrill Gorcunov
2008-07-21 9:12 ` Al Viro
2008-07-21 8:28 ` Al Viro
2008-07-21 8:35 ` Cyrill Gorcunov
2008-07-21 8:42 ` Cyrill Gorcunov
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=488448A1.3030608@cn.fujitsu.com \
--to=lizf@cn.fujitsu.com \
--cc=akpm@linux-foundation.org \
--cc=gorcunov@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@ZenIV.linux.org.uk \
/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.