From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Masami Hiramatsu <mhiramat@kernel.org>
Cc: linux-kernel@vger.kernel.org, Kees Cook <keescook@chromium.org>,
Josef Bacik <jbacik@fb.com>, Thomas Gleixner <tglx@linutronix.de>,
"Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>,
zhong jiang <zhongjiang@huawei.com>
Subject: Re: [PATCH] fail_function: no need to check return value of debugfs_create functions
Date: Wed, 23 Jan 2019 07:33:05 +0100 [thread overview]
Message-ID: <20190123063305.GA25275@kroah.com> (raw)
In-Reply-To: <20190123091141.bfc311d389e48a23af79a8a9@kernel.org>
On Wed, Jan 23, 2019 at 09:11:41AM +0900, Masami Hiramatsu wrote:
> On Tue, 22 Jan 2019 16:21:44 +0100
> Greg Kroah-Hartman <gregkh@linuxfoundation.org> wrote:
>
> > When calling debugfs functions, there is no need to ever check the
> > return value. The function can work or not, but the code logic should
> > never do something different based on this.
>
> Ah, OK. It simplifies the code. But I have a question below,
>
> >
> > Cc: Masami Hiramatsu <mhiramat@kernel.org>
> > Cc: Kees Cook <keescook@chromium.org>
> > Cc: Josef Bacik <jbacik@fb.com>
> > Cc: Thomas Gleixner <tglx@linutronix.de>
> > Cc: "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>
> > Cc: zhong jiang <zhongjiang@huawei.com>
> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > ---
> > kernel/fail_function.c | 23 +++++------------------
> > 1 file changed, 5 insertions(+), 18 deletions(-)
> >
> > diff --git a/kernel/fail_function.c b/kernel/fail_function.c
> > index 17f75b545f66..afc779be5ebb 100644
> > --- a/kernel/fail_function.c
> > +++ b/kernel/fail_function.c
> > @@ -152,20 +152,13 @@ static int fei_retval_get(void *data, u64 *val)
> > DEFINE_DEBUGFS_ATTRIBUTE(fei_retval_ops, fei_retval_get, fei_retval_set,
> > "%llx\n");
> >
> > -static int fei_debugfs_add_attr(struct fei_attr *attr)
> > +static void fei_debugfs_add_attr(struct fei_attr *attr)
> > {
> > struct dentry *dir;
> >
> > dir = debugfs_create_dir(attr->kp.symbol_name, fei_debugfs_dir);
> > - if (!dir)
> > - return -ENOMEM;
> > -
> > - if (!debugfs_create_file("retval", 0600, dir, attr, &fei_retval_ops)) {
> > - debugfs_remove_recursive(dir);
> > - return -ENOMEM;
> > - }
> >
> > - return 0;
>
> Don't we need to check dir here? If above debugfs_create_dir() returns NULL,
> it seems we will create "retval" under root directory of debugfs.
If NULL is returned, your system is out of memory and worse things are
about to happen :)
thanks,
greg k-h
next prev parent reply other threads:[~2019-01-23 6:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-22 15:21 [PATCH] fail_function: no need to check return value of debugfs_create functions Greg Kroah-Hartman
2019-01-23 0:11 ` Masami Hiramatsu
2019-01-23 6:33 ` Greg Kroah-Hartman [this message]
2019-01-23 6:34 ` Greg Kroah-Hartman
2019-01-23 7:33 ` Masami Hiramatsu
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=20190123063305.GA25275@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=jbacik@fb.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=naveen.n.rao@linux.vnet.ibm.com \
--cc=tglx@linutronix.de \
--cc=zhongjiang@huawei.com \
/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.