From: Andrew Morton <akpm@linux-foundation.org>
To: Hillf Danton <dhillf@gmail.com>
Cc: David Rientjes <rientjes@google.com>,
LKML <linux-kernel@vger.kernel.org>,
Al Viro <viro@zeniv.linux.org.uk>
Subject: Re: [PATCH] hugetlbfs: add err code in initializing module
Date: Mon, 12 Mar 2012 16:58:26 -0700 [thread overview]
Message-ID: <20120312165826.c59dc219.akpm@linux-foundation.org> (raw)
In-Reply-To: <CAJd=RBBn35FU99qoXwmPx+FK6=Vt-DXsCje3bAXYB+GrvR9hPg@mail.gmail.com>
On Mon, 12 Mar 2012 20:01:43 +0800
Hillf Danton <dhillf@gmail.com> wrote:
> On Mon, Mar 12, 2012 at 4:25 AM, David Rientjes <rientjes@google.com> wrote:
> >
> > The patch looks good, however, we typically do things like
> >
> > __ __ __ __error = -ENOMEM;
> > __ __ __ __hugetlbfs_inode_cachep = kmem_cache_create(...);
> > __ __ __ __if (!hugetlbfs_inode_cachep)
> > __ __ __ __ __ __ __ __...
> >
> > instead. __Sometimes people grep to see if a call a function that can fail,
> > such as kmem_cache_create(), is followed up by a check for NULL and this
> > would otherwise fail.
> >
> >
> It is updated, thanks David.
>
> -hd
> ===cut here===
> From: Hillf Danton <dhillf@gmail.com>
> Subject: [PATCH] hugetlbfs: add err code in initilizing module
>
> Error code is added if fail to create inode kmem cache, and newly registered
> hugetlb FS is unregistered if fail to mount, both for unlikely corner cases.
>
> Signed-off-by: Hillf Danton <dhillf@gmail.com>
> ---
>
> --- a/fs/hugetlbfs/inode.c Sun Mar 11 12:46:38 2012
> +++ b/fs/hugetlbfs/inode.c Mon Mar 12 19:52:16 2012
> @@ -997,6 +997,7 @@ static int __init init_hugetlbfs_fs(void
> if (error)
> return error;
>
> + error = -ENOMEM;
> hugetlbfs_inode_cachep = kmem_cache_create("hugetlbfs_inode_cache",
> sizeof(struct hugetlbfs_inode_info),
> 0, 0, init_once);
> @@ -1015,6 +1016,7 @@ static int __init init_hugetlbfs_fs(void
> }
>
> error = PTR_ERR(vfsmount);
> + unregister_filesystem(&hugetlbfs_fs_type);
>
> out:
> if (error)
And this, yes?
remove unneeded test of `error'
--- a/fs/hugetlbfs/inode.c~hugetlbfs-return-error-code-when-initializing-module-fix
+++ a/fs/hugetlbfs/inode.c
@@ -1035,8 +1035,7 @@ static int __init init_hugetlbfs_fs(void
unregister_filesystem(&hugetlbfs_fs_type);
out:
- if (error)
- kmem_cache_destroy(hugetlbfs_inode_cachep);
+ kmem_cache_destroy(hugetlbfs_inode_cachep);
out2:
bdi_destroy(&hugetlbfs_backing_dev_info);
return error;
_
next prev parent reply other threads:[~2012-03-12 23:58 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-11 5:09 [PATCH] hugetlbfs: add err code in initializing module Hillf Danton
2012-03-11 5:21 ` Hillf Danton
2012-03-11 20:25 ` David Rientjes
2012-03-12 12:01 ` Hillf Danton
2012-03-12 21:38 ` David Rientjes
2012-03-12 23:58 ` Andrew Morton [this message]
2012-03-22 0:33 ` Al Viro
2012-03-22 13:26 ` Hillf Danton
2012-03-28 7:24 ` David Rientjes
2012-03-28 12:40 ` Hillf Danton
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=20120312165826.c59dc219.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=dhillf@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rientjes@google.com \
--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.