Skip to contentSkip to conversation

crypto: sha-mb - remove a bogus NULL check

PATCH In review Dan Carpenter 3 participants 3 messages Nov 22, 2014 – Nov 25, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: sha-mb - remove a bogus NULL check

This can't be NULL and we dereferenced it earlier. Smatch used to ignore these things where the pointer was obviously non-NULL but I've found that sometimes the intention was to check something else so we were maybe missing bugs.

arch/x86/crypto/sha-mb/sha1_mb.c +1 -2
index 99eefd8..a225a5ca 100644
@@ -204,8 +204,7 @@ static struct sha1_hash_ctx *sha1_ctx_mgr_resubmit(struct sha1_ctx_mgr *mgr, str
 			continue;
 		}
 
-		if (ctx)
-			ctx->status = HASH_CTX_STS_IDLE;
+		ctx->status = HASH_CTX_STS_IDLE;
 		return ctx;
 	}
 
Acked-by on v1 1/1
#1 lore raw
Quoted 12 lines · Dan Carpenter

This can't be NULL and we dereferenced it earlier. Smatch used to ignore these things where the pointer was obviously non-NULL but I've found that sometimes the intention was to check something else so we were maybe missing bugs.

arch/x86/crypto/sha-mb/sha1_mb.c +0 -0
index 99eefd8..a225a5ca 100644

arch/x86/crypto/sha-mb/sha1_mb.c static struct sha1_hash_ctx *sha1_ctx_mgr_resubmit(struct sha1_ctx_mgr *mgr, str · line 210

Quoted 9 lines
arch/x86/crypto/sha-mb/sha1_mb.c +1 -2
@@ -204,8 +204,7 @@ static struct sha1_hash_ctx *sha1_ctx_mgr_resubmit(struct sha1_ctx_mgr *mgr, str
 			continue;
 		}
 
-		if (ctx)
-			ctx->status = HASH_CTX_STS_IDLE;
+		ctx->status = HASH_CTX_STS_IDLE;
 		return ctx;
 	}
 

Agree. This NULL pointer check is not necessary.

maintainer
#2 lore raw
In reply to Dan Carpenter
Quoted 6 lines · Dan Carpenter

This can't be NULL and we dereferenced it earlier. Smatch used to ignore these things where the pointer was obviously non-NULL but I've found that sometimes the intention was to check something else so we were maybe missing bugs.

Patch applied. Thanks!

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt