Skip to content

Commit 3ffcd6c

Browse files
tobluxgregkh
authored andcommitted
crypto: atmel-aes - guard unregister on error in atmel_aes_register_algs
[ Upstream commit 57a1394 ] Ensure the device supports XTS and GCM with 'has_xts' and 'has_gcm' before unregistering algorithms when XTS or authenc registration fails, which would trigger a WARN in crypto_unregister_alg(). Currently, with the capabilities defined in atmel_aes_get_cap(), this bug cannot happen because all devices that support XTS and authenc also support GCM, but the error handling should still be correct regardless of hardware capabilities. Fixes: d52db51 ("crypto: atmel-aes - add support to the XTS mode") Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent f4b747f commit 3ffcd6c

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

drivers/crypto/atmel-aes.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2270,10 +2270,12 @@ static int atmel_aes_register_algs(struct atmel_aes_dev *dd)
22702270
/* i = ARRAY_SIZE(aes_authenc_algs); */
22712271
err_aes_authenc_alg:
22722272
crypto_unregister_aeads(aes_authenc_algs, i);
2273-
crypto_unregister_skcipher(&aes_xts_alg);
2273+
if (dd->caps.has_xts)
2274+
crypto_unregister_skcipher(&aes_xts_alg);
22742275
#endif
22752276
err_aes_xts_alg:
2276-
crypto_unregister_aead(&aes_gcm_alg);
2277+
if (dd->caps.has_gcm)
2278+
crypto_unregister_aead(&aes_gcm_alg);
22772279
err_aes_gcm_alg:
22782280
i = ARRAY_SIZE(aes_algs);
22792281
err_aes_algs:

0 commit comments

Comments
 (0)