public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Anton Vorontsov <anton@enomsg.org>,
	Colin Cross <ccross@android.com>, Tony Luck <tony.luck@intel.com>,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] pstore: Tidy up an error check
Date: Wed, 2 Dec 2020 11:25:46 -0800	[thread overview]
Message-ID: <202012021124.ADBFCE999@keescook> (raw)
In-Reply-To: <X8c4C2q6qaZ8qX6L@mwanda>

On Wed, Dec 02, 2020 at 09:45:31AM +0300, Dan Carpenter wrote:
> The crypto_alloc_comp() function never returns NULL, it returns error
> pointers on error.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

I replied to an identical patch yesterday, actually:
https://lore.kernel.org/lkml/202012011215.B9BF24A6D@keescook/

Using IS_ERR_OR_NULL() is more robust, and this isn't fast path, so I'd
prefer to keep it that way.

-Kees

> ---
>  fs/pstore/platform.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
> index 36714df37d5d..b7a2a2a31dee 100644
> --- a/fs/pstore/platform.c
> +++ b/fs/pstore/platform.c
> @@ -315,7 +315,7 @@ static void allocate_buf_for_compression(void)
>  	}
>  
>  	ctx = crypto_alloc_comp(zbackend->name, 0, 0);
> -	if (IS_ERR_OR_NULL(ctx)) {
> +	if (IS_ERR(ctx)) {
>  		kfree(buf);
>  		pr_err("crypto_alloc_comp('%s') failed: %ld\n", zbackend->name,
>  		       PTR_ERR(ctx));
> -- 
> 2.29.2
> 

-- 
Kees Cook

  reply	other threads:[~2020-12-02 19:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-02  6:45 [PATCH] pstore: Tidy up an error check Dan Carpenter
2020-12-02 19:25 ` Kees Cook [this message]
2020-12-02 20:00   ` Dan Carpenter

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=202012021124.ADBFCE999@keescook \
    --to=keescook@chromium.org \
    --cc=anton@enomsg.org \
    --cc=ccross@android.com \
    --cc=dan.carpenter@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tony.luck@intel.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