public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Wang Ming <machel@vivo.com>
Cc: David Hildenbrand <david@redhat.com>,
	Akinobu Mita <akinobu.mita@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org, opensource.kernel@vivo.com
Subject: Re: [PATCH v1] lib:Fix an NULL vs IS_ERR() bug for debugfs_create_dir() in err_inject_init()
Date: Wed, 12 Jul 2023 18:34:48 +0200	[thread overview]
Message-ID: <2023071202-varsity-evasion-580b@gregkh> (raw)
In-Reply-To: <20230712135226.10041-1-machel@vivo.com>

On Wed, Jul 12, 2023 at 09:52:11PM +0800, Wang Ming wrote:
> The debugfs_create_dir() function returns error pointers.
> It never returns NULL. Most incorrect error checks were fixed,
> but the one in err_inject_init() was forgotten.
> 
> Fix the remaining error check.
> 
> Signed-off-by: Wang Ming <machel@vivo.com>
> ---
>  lib/notifier-error-inject.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/notifier-error-inject.c b/lib/notifier-error-inject.c
> index 2b24ea6c9497..c49354c23802 100644
> --- a/lib/notifier-error-inject.c
> +++ b/lib/notifier-error-inject.c
> @@ -83,7 +83,7 @@ static int __init err_inject_init(void)
>  	notifier_err_inject_dir =
>  		debugfs_create_dir("notifier-error-inject", NULL);
>  
> -	if (!notifier_err_inject_dir)
> +	if (IS_ERR(notifier_err_inject_dir))
>  		return -ENOMEM;

Please do not do any different codepath if a debugfs_*() call fails or
succeeds.

Why do you need to check this at all?

And why are you creating this directory at the root of debugfs?

thanks,

greg k-h

  reply	other threads:[~2023-07-12 16:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-12 13:52 [PATCH v1] lib:Fix an NULL vs IS_ERR() bug for debugfs_create_dir() in err_inject_init() Wang Ming
2023-07-12 16:34 ` Greg Kroah-Hartman [this message]
     [not found]   ` <SG2PR06MB37435A03DEC11F265C849093BD37A@SG2PR06MB3743.apcprd06.prod.outlook.com>
2023-07-13  6:01     ` 回复: " 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=2023071202-varsity-evasion-580b@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=akinobu.mita@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=machel@vivo.com \
    --cc=opensource.kernel@vivo.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox