linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pstore: Fix passing zero to 'PTR_ERR' warning
@ 2020-10-31  5:59 YueHaibing
  2020-12-01 20:16 ` Kees Cook
  0 siblings, 1 reply; 2+ messages in thread
From: YueHaibing @ 2020-10-31  5:59 UTC (permalink / raw)
  To: keescook, anton, ccross, tony.luck; +Cc: linux-kernel, YueHaibing

Fix smatch warning:

fs/pstore/platform.c:320 allocate_buf_for_compression() warn: passing zero to 'PTR_ERR'

crypto_alloc_comp() never return NULL, use IS_ERR
instead of IS_ERR_OR_NULL to fix this.

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 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.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] pstore: Fix passing zero to 'PTR_ERR' warning
  2020-10-31  5:59 [PATCH] pstore: Fix passing zero to 'PTR_ERR' warning YueHaibing
@ 2020-12-01 20:16 ` Kees Cook
  0 siblings, 0 replies; 2+ messages in thread
From: Kees Cook @ 2020-12-01 20:16 UTC (permalink / raw)
  To: YueHaibing; +Cc: anton, ccross, tony.luck, linux-kernel

On Sat, Oct 31, 2020 at 01:59:31PM +0800, YueHaibing wrote:
> Fix smatch warning:
> 
> fs/pstore/platform.c:320 allocate_buf_for_compression() warn: passing zero to 'PTR_ERR'
> 
> crypto_alloc_comp() never return NULL, use IS_ERR
> instead of IS_ERR_OR_NULL to fix this.
> 
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>

Hmm, well, if I get back a NULL ctx, I still can't use it, so I prefer
to remain overly defensive in this code.

Thanks for looking in to it, though! If you see some more compelling
reason to do this, let me know.

-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.17.1
> 

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-12-01 20:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-31  5:59 [PATCH] pstore: Fix passing zero to 'PTR_ERR' warning YueHaibing
2020-12-01 20:16 ` Kees Cook

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).