All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Yi Yang <yiyang13@huawei.com>
Cc: akpm@linux-foundation.org, machel@vivo.com, mhiramat@kernel.org,
	ast@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] lib: error-inject: fix error check for debugfs_create_file()
Date: Thu, 31 Aug 2023 10:10:33 +0200	[thread overview]
Message-ID: <2023083151-random-karma-fa97@gregkh> (raw)
In-Reply-To: <20230831075653.238562-1-yiyang13@huawei.com>

On Thu, Aug 31, 2023 at 03:56:53PM +0800, Yi Yang wrote:
> The debugfs_create_file() function returns error pointers, it never
> returns NULL, we need to check the return value correctly to avoid
> debugfs_remove() is not called.
> 
> Fixes: 540adea3809f ("error-injection: Separate error-injection from kprobe")
> Signed-off-by: Yi Yang <yiyang13@huawei.com>
> ---
>  lib/error-inject.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/error-inject.c b/lib/error-inject.c
> index 887acd9a6ea6..8bcdea5229eb 100644
> --- a/lib/error-inject.c
> +++ b/lib/error-inject.c
> @@ -219,7 +219,7 @@ static int __init ei_debugfs_init(void)
>  	dir = debugfs_create_dir("error_injection", NULL);
>  
>  	file = debugfs_create_file("list", 0444, dir, NULL, &ei_fops);
> -	if (!file) {
> +	if (IS_ERR(file)) {

As it is obvious this check has never failed, please just don't check
this at all, it's fine to never check the return value of this function.

thanks,

greg k-h

      reply	other threads:[~2023-08-31  8:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-31  7:56 [PATCH] lib: error-inject: fix error check for debugfs_create_file() Yi Yang
2023-08-31  8:10 ` Greg KH [this message]

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=2023083151-random-karma-fa97@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=ast@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=machel@vivo.com \
    --cc=mhiramat@kernel.org \
    --cc=yiyang13@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.