[PATCH 1/2] crypto: chcr - Improve error checking

From: Christophe JAILLET
Date: Thu Apr 13 2017 - 08:14:25 EST


'chcr_alloc_shash()' can return NULL. Here it is not possible because this
code is reached only if 'get_alg_config()' a few lines above has succeeded.
So we are garanteed that the value of 'max_authsize' is a correct
parameter.
Anyway, this is harmless to add a check for NULL.

Signed-off-by: Christophe JAILLET <christophe.jaillet@xxxxxxxxxx>
---
drivers/crypto/chelsio/chcr_algo.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/chelsio/chcr_algo.c b/drivers/crypto/chelsio/chcr_algo.c
index 41bc7f4f58cd..f19590ac8775 100644
--- a/drivers/crypto/chelsio/chcr_algo.c
+++ b/drivers/crypto/chelsio/chcr_algo.c
@@ -2294,7 +2294,7 @@ static int chcr_authenc_setkey(struct crypto_aead *authenc, const u8 *key,
aeadctx->enckey_len << 3);

base_hash = chcr_alloc_shash(max_authsize);
- if (IS_ERR(base_hash)) {
+ if (IS_ERR_OR_NULL(base_hash)) {
pr_err("chcr : Base driver cannot be loaded\n");
goto out;
}
--
2.11.0