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: cryptd - convert to new way of freeing instances

Convert the "cryptd" template to the new way of freeing instances, where
a ->free() method is installed to the instance struct itself. This
replaces the weakly-typed method crypto_template::free().

This will allow removing support for the old way of freeing instances.

Note that the 'default' case in cryptd_free() was already unreachable.
So, we aren't missing anything by keeping only the ahash and aead parts.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Eric Biggers and committed by
Herbert Xu
758ec5ac 0f8f6d86

+20 -22
+20 -22
crypto/cryptd.c
··· 631 631 return crypto_shash_import(desc, in); 632 632 } 633 633 634 + static void cryptd_hash_free(struct ahash_instance *inst) 635 + { 636 + struct hashd_instance_ctx *ctx = ahash_instance_ctx(inst); 637 + 638 + crypto_drop_shash(&ctx->spawn); 639 + kfree(inst); 640 + } 641 + 634 642 static int cryptd_create_hash(struct crypto_template *tmpl, struct rtattr **tb, 635 643 struct cryptd_queue *queue) 636 644 { ··· 688 680 if (crypto_shash_alg_has_setkey(alg)) 689 681 inst->alg.setkey = cryptd_hash_setkey; 690 682 inst->alg.digest = cryptd_hash_digest_enqueue; 683 + 684 + inst->free = cryptd_hash_free; 691 685 692 686 err = ahash_register_instance(tmpl, inst); 693 687 if (err) { ··· 818 808 crypto_free_aead(ctx->child); 819 809 } 820 810 811 + static void cryptd_aead_free(struct aead_instance *inst) 812 + { 813 + struct aead_instance_ctx *ctx = aead_instance_ctx(inst); 814 + 815 + crypto_drop_aead(&ctx->aead_spawn); 816 + kfree(inst); 817 + } 818 + 821 819 static int cryptd_create_aead(struct crypto_template *tmpl, 822 820 struct rtattr **tb, 823 821 struct cryptd_queue *queue) ··· 875 857 inst->alg.encrypt = cryptd_aead_encrypt_enqueue; 876 858 inst->alg.decrypt = cryptd_aead_decrypt_enqueue; 877 859 860 + inst->free = cryptd_aead_free; 861 + 878 862 err = aead_register_instance(tmpl, inst); 879 863 if (err) { 880 864 out_drop_aead: ··· 909 889 return -EINVAL; 910 890 } 911 891 912 - static void cryptd_free(struct crypto_instance *inst) 913 - { 914 - struct cryptd_instance_ctx *ctx = crypto_instance_ctx(inst); 915 - struct hashd_instance_ctx *hctx = crypto_instance_ctx(inst); 916 - struct aead_instance_ctx *aead_ctx = crypto_instance_ctx(inst); 917 - 918 - switch (inst->alg.cra_flags & CRYPTO_ALG_TYPE_MASK) { 919 - case CRYPTO_ALG_TYPE_AHASH: 920 - crypto_drop_shash(&hctx->spawn); 921 - kfree(ahash_instance(inst)); 922 - return; 923 - case CRYPTO_ALG_TYPE_AEAD: 924 - crypto_drop_aead(&aead_ctx->aead_spawn); 925 - kfree(aead_instance(inst)); 926 - return; 927 - default: 928 - crypto_drop_spawn(&ctx->spawn); 929 - kfree(inst); 930 - } 931 - } 932 - 933 892 static struct crypto_template cryptd_tmpl = { 934 893 .name = "cryptd", 935 894 .create = cryptd_create, 936 - .free = cryptd_free, 937 895 .module = THIS_MODULE, 938 896 }; 939 897