path: root/crypto
diff options
authorArd Biesheuvel <>2021-03-02 21:33:03 +0100
committerHerbert Xu <>2021-03-13 00:04:01 +1100
commit83681f2bebb34dbb3f03fecd8f570308ab8b7c2c (patch)
treee77d6a6d5d4eb8a24caf9af6241ead46922c34b6 /crypto
parent98b5ef3e97b16eaeeedb936f8bda3594ff84a70e (diff)
crypto: api - check for ERR pointers in crypto_destroy_tfm()
Given that crypto_alloc_tfm() may return ERR pointers, and to avoid crashes on obscure error paths where such pointers are presented to crypto_destroy_tfm() (such as [0]), add an ERR_PTR check there before dereferencing the second argument as a struct crypto_tfm pointer. [0] Reported-by: Reviewed-by: Eric Biggers <> Signed-off-by: Ard Biesheuvel <> Signed-off-by: Herbert Xu <>
Diffstat (limited to 'crypto')
1 files changed, 1 insertions, 1 deletions
diff --git a/crypto/api.c b/crypto/api.c
index ed08cbd5b9d3..c4eda56cff89 100644
--- a/crypto/api.c
+++ b/crypto/api.c
@@ -562,7 +562,7 @@ void crypto_destroy_tfm(void *mem, struct crypto_tfm *tfm)
struct crypto_alg *alg;
- if (unlikely(!mem))
+ if (IS_ERR_OR_NULL(mem))
alg = tfm->__crt_alg;