Skip to contentSkip to conversation

pstore: Fix passing zero to 'PTR_ERR' warning

PATCH In review YueHaibing 2 participants 2 messages Oct 31, 2020 – Dec 1, 2020 Pstore filesystem

lore
Share & tools
lore

YueHaibing

author
#0 lore raw

PATCH 1/1 pstore: Fix passing zero to 'PTR_ERR' warning

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.

---
 fs/pstore/platform.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/pstore/platform.c +1 -1
index 36714df37d5d..b7a2a2a31dee 100644
@@ -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));
Signature · 1 line
2.17.1
#1 lore raw
Quoted 8 lines · 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.

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

Quoted 20 lines
---
 fs/pstore/platform.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/pstore/platform.c +1 -1
index 36714df37d5d..b7a2a2a31dee 100644
@@ -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));
Signature · 1 line
2.17.1
Signature · 1 line
Kees Cook