crypto: keembay: Fix AEAD unregister count in error path
Subsystems (2)
PATCH 1/1 crypto: keembay: Fix AEAD unregister count in error path
register_aes_algs() registers the AEAD algorithms before registering the skcipher algorithms. If skcipher registration fails, the function unwinds the earlier AEAD registration with crypto_engine_unregister_aeads(), but it passes ARRAY_SIZE(algs), which is the skcipher table size.
Use ARRAY_SIZE(algs_aead) for the AEAD unwind path so the unregister helper iterates over the same table that was registered. Also clarify the nearby
comment: the crypto registration helpers clean up algorithms registered within the same call, while this function must still unwind earlier successful registration steps.
--- drivers/crypto/intel/keembay/keembay-ocs-aes-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/intel/keembay/keembay-ocs-aes-core.c +2 -2
@@ -1541,7 +1541,7 @@ static int register_aes_algs(struct ocs_aes_dev *aes_dev)/* * If any algorithm fails to register, all preceding algorithms that -* were successfully registered will be automatically unregistered. +* were registered in the same call are automatically unregistered. */ ret =crypto_engine_register_aeads (algs_aead,ARRAY_SIZE (algs_aead));if (ret)
@@ -1549,7 +1549,7 @@ static int register_aes_algs(struct ocs_aes_dev *aes_dev) ret =crypto_engine_register_skciphers (algs,ARRAY_SIZE (algs));if (ret) -crypto_engine_unregister_aeads (algs_aead,ARRAY_SIZE (algs)); +crypto_engine_unregister_aeads (algs_aead,ARRAY_SIZE (algs_aead));return ret; }
Signature · 1 line
2.47.1
Herbert Xu
maintainerQuoted 11 lines · Myeonghun Pak
register_aes_algs()registers the AEAD algorithms before registering the skcipher algorithms. If skcipher registration fails, the function unwinds the earlier AEAD registration withcrypto_engine_unregister_aeads(), but it passesARRAY_SIZE(algs), which is the skcipher table size.Use
ARRAY_SIZE(algs_aead)for the AEAD unwind path so the unregister helper iterates over the same table that was registered. Also clarify the nearby
comment: the crypto registration helpers clean up algorithms registered within the same call, while this function must still unwind earlier successful registration steps.
Quoted 8 lines
Fixes 885743324513 ("crypto: keembay - Add support for Keem Bay OCS AES/SM4")Co-developed-by Ijae Kim <[email protected]>Signed-off-by Ijae Kim <[email protected]>Signed-off-by Myeonghun Pak <[email protected]>--- drivers/crypto/intel/keembay/keembay-ocs-aes-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
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