public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Arnd Bergmann <arnd@arndb.de>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] lkdtm: no need to check return value of debugfs_create functions
Date: Tue, 11 Jun 2019 11:44:53 -0700	[thread overview]
Message-ID: <201906111144.3E05EAA80@keescook> (raw)
In-Reply-To: <20190611183213.GA31645@kroah.com>

On Tue, Jun 11, 2019 at 08:32:13PM +0200, Greg Kroah-Hartman 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.

What is the user-visible feedback when, say, debugfs_create_file()
fails? And what happens when debugfs_create_file() passes in a NULL
root?

-Kees

> 
> Cc: Kees Cook <keescook@chromium.org>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
>  drivers/misc/lkdtm/core.c | 13 ++-----------
>  1 file changed, 2 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/misc/lkdtm/core.c b/drivers/misc/lkdtm/core.c
> index 1972dad966f5..bae3b3763f3e 100644
> --- a/drivers/misc/lkdtm/core.c
> +++ b/drivers/misc/lkdtm/core.c
> @@ -429,22 +429,13 @@ static int __init lkdtm_module_init(void)
>  
>  	/* Register debugfs interface */
>  	lkdtm_debugfs_root = debugfs_create_dir("provoke-crash", NULL);
> -	if (!lkdtm_debugfs_root) {
> -		pr_err("creating root dir failed\n");
> -		return -ENODEV;
> -	}
>  
>  	/* Install debugfs trigger files. */
>  	for (i = 0; i < ARRAY_SIZE(crashpoints); i++) {
>  		struct crashpoint *cur = &crashpoints[i];
> -		struct dentry *de;
>  
> -		de = debugfs_create_file(cur->name, 0644, lkdtm_debugfs_root,
> -					 cur, &cur->fops);
> -		if (de == NULL) {
> -			pr_err("could not create crashpoint %s\n", cur->name);
> -			goto out_err;
> -		}
> +		debugfs_create_file(cur->name, 0644, lkdtm_debugfs_root, cur,
> +				    &cur->fops);
>  	}
>  
>  	/* Install crashpoint if one was selected. */
> -- 
> 2.22.0
> 

-- 
Kees Cook

  reply	other threads:[~2019-06-11 18:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-11 18:32 [PATCH] lkdtm: no need to check return value of debugfs_create functions Greg Kroah-Hartman
2019-06-11 18:44 ` Kees Cook [this message]
2019-06-11 18:56   ` Greg Kroah-Hartman
2019-06-11 20:43 ` Kees Cook
2019-06-12 11:36   ` Greg Kroah-Hartman

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=201906111144.3E05EAA80@keescook \
    --to=keescook@chromium.org \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox