]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
crypto: atmel-aes - guard unregister on error in atmel_aes_register_algs
authorThorsten Blum <thorsten.blum@linux.dev>
Wed, 11 Mar 2026 11:39:28 +0000 (12:39 +0100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Sun, 22 Mar 2026 02:17:58 +0000 (11:17 +0900)
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: d52db5188a87 ("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>
drivers/crypto/atmel-aes.c

index 9b0cb97055dc5ccd9cd6ca1b57a83b24ed2d802f..b393689400b4c17294cba73fcd16567fdd6687f4 100644 (file)
@@ -2270,10 +2270,12 @@ static int atmel_aes_register_algs(struct atmel_aes_dev *dd)
        /* i = ARRAY_SIZE(aes_authenc_algs); */
 err_aes_authenc_alg:
        crypto_unregister_aeads(aes_authenc_algs, i);
-       crypto_unregister_skcipher(&aes_xts_alg);
+       if (dd->caps.has_xts)
+               crypto_unregister_skcipher(&aes_xts_alg);
 #endif
 err_aes_xts_alg:
-       crypto_unregister_aead(&aes_gcm_alg);
+       if (dd->caps.has_gcm)
+               crypto_unregister_aead(&aes_gcm_alg);
 err_aes_gcm_alg:
        i = ARRAY_SIZE(aes_algs);
 err_aes_algs: