Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

crypto: hash - Fix clone error handling

Do not copy the exit function in crypto_clone_tfm as it should
only be set after init_tfm or clone_tfm has succeeded.

Move the setting into crypto_clone_ahash and crypto_clone_shash
instead.

Also clone the fb if necessary.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

+21 -3
+17 -2
crypto/ahash.c
··· 877 877 { 878 878 struct hash_alg_common *halg = crypto_hash_alg_common(hash); 879 879 struct crypto_tfm *tfm = crypto_ahash_tfm(hash); 880 + struct crypto_ahash *fb = NULL; 880 881 struct crypto_ahash *nhash; 881 882 struct ahash_alg *alg; 882 883 int err; ··· 907 906 err = PTR_ERR(shash); 908 907 goto out_free_nhash; 909 908 } 909 + crypto_ahash_tfm(nhash)->exit = crypto_exit_ahash_using_shash; 910 910 nhash->using_shash = true; 911 911 *nctx = shash; 912 912 return nhash; 913 913 } 914 914 915 + if (ahash_is_async(hash)) { 916 + fb = crypto_clone_ahash(crypto_ahash_fb(hash)); 917 + err = PTR_ERR(fb); 918 + if (IS_ERR(fb)) 919 + goto out_free_nhash; 920 + 921 + crypto_ahash_tfm(nhash)->fb = crypto_ahash_tfm(fb); 922 + } 923 + 915 924 err = -ENOSYS; 916 925 alg = crypto_ahash_alg(hash); 917 926 if (!alg->clone_tfm) 918 - goto out_free_nhash; 927 + goto out_free_fb; 919 928 920 929 err = alg->clone_tfm(nhash, hash); 921 930 if (err) 922 - goto out_free_nhash; 931 + goto out_free_fb; 932 + 933 + crypto_ahash_tfm(nhash)->exit = crypto_ahash_exit_tfm; 923 934 924 935 return nhash; 925 936 937 + out_free_fb: 938 + crypto_free_ahash(fb); 926 939 out_free_nhash: 927 940 crypto_free_ahash(nhash); 928 941 return ERR_PTR(err);
+1 -1
crypto/api.c
··· 570 570 571 571 tfm = (struct crypto_tfm *)(mem + frontend->tfmsize); 572 572 tfm->crt_flags = otfm->crt_flags; 573 - tfm->exit = otfm->exit; 573 + tfm->fb = tfm; 574 574 575 575 out: 576 576 return mem;
+3
crypto/shash.c
··· 413 413 } 414 414 } 415 415 416 + if (alg->exit_tfm) 417 + crypto_shash_tfm(nhash)->exit = crypto_shash_exit_tfm; 418 + 416 419 return nhash; 417 420 } 418 421 EXPORT_SYMBOL_GPL(crypto_clone_shash);