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: shash - convert shash_free_instance() to new style

Convert shash_free_instance() and its users 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.

Also give shash_free_instance() a more descriptive name to reflect that
it's only for instances with a single spawn, not for any instance.

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
a39c66cc 758ec5ac

+20 -15
+3 -2
crypto/ccm.c
··· 927 927 inst->alg.final = crypto_cbcmac_digest_final; 928 928 inst->alg.setkey = crypto_cbcmac_digest_setkey; 929 929 930 + inst->free = shash_free_singlespawn_instance; 931 + 930 932 err = shash_register_instance(tmpl, inst); 931 933 if (err) { 932 934 err_free_inst: 933 - shash_free_instance(shash_crypto_instance(inst)); 935 + shash_free_singlespawn_instance(inst); 934 936 } 935 937 return err; 936 938 } ··· 941 939 { 942 940 .name = "cbcmac", 943 941 .create = cbcmac_create, 944 - .free = shash_free_instance, 945 942 .module = THIS_MODULE, 946 943 }, { 947 944 .name = "ccm_base",
+3 -2
crypto/cmac.c
··· 280 280 inst->alg.final = crypto_cmac_digest_final; 281 281 inst->alg.setkey = crypto_cmac_digest_setkey; 282 282 283 + inst->free = shash_free_singlespawn_instance; 284 + 283 285 err = shash_register_instance(tmpl, inst); 284 286 if (err) { 285 287 err_free_inst: 286 - shash_free_instance(shash_crypto_instance(inst)); 288 + shash_free_singlespawn_instance(inst); 287 289 } 288 290 return err; 289 291 } ··· 293 291 static struct crypto_template crypto_cmac_tmpl = { 294 292 .name = "cmac", 295 293 .create = cmac_create, 296 - .free = shash_free_instance, 297 294 .module = THIS_MODULE, 298 295 }; 299 296
+3 -2
crypto/hmac.c
··· 224 224 inst->alg.init_tfm = hmac_init_tfm; 225 225 inst->alg.exit_tfm = hmac_exit_tfm; 226 226 227 + inst->free = shash_free_singlespawn_instance; 228 + 227 229 err = shash_register_instance(tmpl, inst); 228 230 if (err) { 229 231 err_free_inst: 230 - shash_free_instance(shash_crypto_instance(inst)); 232 + shash_free_singlespawn_instance(inst); 231 233 } 232 234 return err; 233 235 } ··· 237 235 static struct crypto_template hmac_tmpl = { 238 236 .name = "hmac", 239 237 .create = hmac_create, 240 - .free = shash_free_instance, 241 238 .module = THIS_MODULE, 242 239 }; 243 240
+4 -4
crypto/shash.c
··· 590 590 } 591 591 EXPORT_SYMBOL_GPL(shash_register_instance); 592 592 593 - void shash_free_instance(struct crypto_instance *inst) 593 + void shash_free_singlespawn_instance(struct shash_instance *inst) 594 594 { 595 - crypto_drop_spawn(crypto_instance_ctx(inst)); 596 - kfree(shash_instance(inst)); 595 + crypto_drop_spawn(shash_instance_ctx(inst)); 596 + kfree(inst); 597 597 } 598 - EXPORT_SYMBOL_GPL(shash_free_instance); 598 + EXPORT_SYMBOL_GPL(shash_free_singlespawn_instance); 599 599 600 600 MODULE_LICENSE("GPL"); 601 601 MODULE_DESCRIPTION("Synchronous cryptographic hash type");
+3 -2
crypto/vmac.c
··· 660 660 inst->alg.final = vmac_final; 661 661 inst->alg.setkey = vmac_setkey; 662 662 663 + inst->free = shash_free_singlespawn_instance; 664 + 663 665 err = shash_register_instance(tmpl, inst); 664 666 if (err) { 665 667 err_free_inst: 666 - shash_free_instance(shash_crypto_instance(inst)); 668 + shash_free_singlespawn_instance(inst); 667 669 } 668 670 return err; 669 671 } ··· 673 671 static struct crypto_template vmac64_tmpl = { 674 672 .name = "vmac64", 675 673 .create = vmac_create, 676 - .free = shash_free_instance, 677 674 .module = THIS_MODULE, 678 675 }; 679 676
+3 -2
crypto/xcbc.c
··· 239 239 inst->alg.final = crypto_xcbc_digest_final; 240 240 inst->alg.setkey = crypto_xcbc_digest_setkey; 241 241 242 + inst->free = shash_free_singlespawn_instance; 243 + 242 244 err = shash_register_instance(tmpl, inst); 243 245 if (err) { 244 246 err_free_inst: 245 - shash_free_instance(shash_crypto_instance(inst)); 247 + shash_free_singlespawn_instance(inst); 246 248 } 247 249 return err; 248 250 } ··· 252 250 static struct crypto_template crypto_xcbc_tmpl = { 253 251 .name = "xcbc", 254 252 .create = xcbc_create, 255 - .free = shash_free_instance, 256 253 .module = THIS_MODULE, 257 254 }; 258 255
+1 -1
include/crypto/internal/hash.h
··· 125 125 void crypto_unregister_shashes(struct shash_alg *algs, int count); 126 126 int shash_register_instance(struct crypto_template *tmpl, 127 127 struct shash_instance *inst); 128 - void shash_free_instance(struct crypto_instance *inst); 128 + void shash_free_singlespawn_instance(struct shash_instance *inst); 129 129 130 130 int crypto_grab_shash(struct crypto_shash_spawn *spawn, 131 131 struct crypto_instance *inst,