aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Tuchscherer <ingo.tuchscherer@de.ibm.com>2013-10-15 05:24:07 -0400
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2013-10-24 11:17:10 -0400
commit4f57ba716b12ab939d46b7910768c3da3623fdc1 (patch)
treef67e873f2e931ae677a6795e11b63b8e3c18a505
parentdc3ac5ff82e768385a7c787a211cfb131bc1924b (diff)
s390/crypto: fix aes_s390 crypto module unload problem
If a machine has no hardware support for the xts-aes or ctr-aes algorithms they are not registered in aes_s390_init. But aes_s390_fini unconditionally unregisters the algorithms which causes crypto_remove_alg to crash. Add two flag variables to remember if xts-aes and ctr-aes have been added. Signed-off-by: Ingo Tuchscherer <ingo.tuchscherer@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
-rw-r--r--arch/s390/crypto/aes_s390.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/arch/s390/crypto/aes_s390.c b/arch/s390/crypto/aes_s390.c
index b4dbade8ca24..46cae138ece2 100644
--- a/arch/s390/crypto/aes_s390.c
+++ b/arch/s390/crypto/aes_s390.c
@@ -725,6 +725,8 @@ static struct crypto_alg xts_aes_alg = {
725 } 725 }
726}; 726};
727 727
728static int xts_aes_alg_reg;
729
728static int ctr_aes_set_key(struct crypto_tfm *tfm, const u8 *in_key, 730static int ctr_aes_set_key(struct crypto_tfm *tfm, const u8 *in_key,
729 unsigned int key_len) 731 unsigned int key_len)
730{ 732{
@@ -846,6 +848,8 @@ static struct crypto_alg ctr_aes_alg = {
846 } 848 }
847}; 849};
848 850
851static int ctr_aes_alg_reg;
852
849static int __init aes_s390_init(void) 853static int __init aes_s390_init(void)
850{ 854{
851 int ret; 855 int ret;
@@ -884,6 +888,7 @@ static int __init aes_s390_init(void)
884 ret = crypto_register_alg(&xts_aes_alg); 888 ret = crypto_register_alg(&xts_aes_alg);
885 if (ret) 889 if (ret)
886 goto xts_aes_err; 890 goto xts_aes_err;
891 xts_aes_alg_reg = 1;
887 } 892 }
888 893
889 if (crypt_s390_func_available(KMCTR_AES_128_ENCRYPT, 894 if (crypt_s390_func_available(KMCTR_AES_128_ENCRYPT,
@@ -902,6 +907,7 @@ static int __init aes_s390_init(void)
902 free_page((unsigned long) ctrblk); 907 free_page((unsigned long) ctrblk);
903 goto ctr_aes_err; 908 goto ctr_aes_err;
904 } 909 }
910 ctr_aes_alg_reg = 1;
905 } 911 }
906 912
907out: 913out:
@@ -921,9 +927,12 @@ aes_err:
921 927
922static void __exit aes_s390_fini(void) 928static void __exit aes_s390_fini(void)
923{ 929{
924 crypto_unregister_alg(&ctr_aes_alg); 930 if (ctr_aes_alg_reg) {
925 free_page((unsigned long) ctrblk); 931 crypto_unregister_alg(&ctr_aes_alg);
926 crypto_unregister_alg(&xts_aes_alg); 932 free_page((unsigned long) ctrblk);
933 }
934 if (xts_aes_alg_reg)
935 crypto_unregister_alg(&xts_aes_alg);
927 crypto_unregister_alg(&cbc_aes_alg); 936 crypto_unregister_alg(&cbc_aes_alg);
928 crypto_unregister_alg(&ecb_aes_alg); 937 crypto_unregister_alg(&ecb_aes_alg);
929 crypto_unregister_alg(&aes_alg); 938 crypto_unregister_alg(&aes_alg);