@@ -369,7 +369,6 @@ static int cryptd_create_skcipher(struct crypto_template *tmpl,
369369 struct skcipherd_instance_ctx * ctx ;
370370 struct skcipher_instance * inst ;
371371 struct skcipher_alg * alg ;
372- const char * name ;
373372 u32 type ;
374373 u32 mask ;
375374 int err ;
@@ -379,10 +378,6 @@ static int cryptd_create_skcipher(struct crypto_template *tmpl,
379378
380379 cryptd_check_internal (tb , & type , & mask );
381380
382- name = crypto_attr_alg_name (tb [1 ]);
383- if (IS_ERR (name ))
384- return PTR_ERR (name );
385-
386381 inst = kzalloc (sizeof (* inst ) + sizeof (* ctx ), GFP_KERNEL );
387382 if (!inst )
388383 return - ENOMEM ;
@@ -391,14 +386,14 @@ static int cryptd_create_skcipher(struct crypto_template *tmpl,
391386 ctx -> queue = queue ;
392387
393388 err = crypto_grab_skcipher (& ctx -> spawn , skcipher_crypto_instance (inst ),
394- name , type , mask );
389+ crypto_attr_alg_name ( tb [ 1 ]) , type , mask );
395390 if (err )
396- goto out_free_inst ;
391+ goto err_free_inst ;
397392
398393 alg = crypto_spawn_skcipher_alg (& ctx -> spawn );
399394 err = cryptd_init_instance (skcipher_crypto_instance (inst ), & alg -> base );
400395 if (err )
401- goto out_drop_skcipher ;
396+ goto err_free_inst ;
402397
403398 inst -> alg .base .cra_flags = CRYPTO_ALG_ASYNC |
404399 (alg -> base .cra_flags & CRYPTO_ALG_INTERNAL );
@@ -421,10 +416,8 @@ static int cryptd_create_skcipher(struct crypto_template *tmpl,
421416
422417 err = skcipher_register_instance (tmpl , inst );
423418 if (err ) {
424- out_drop_skcipher :
425- crypto_drop_skcipher (& ctx -> spawn );
426- out_free_inst :
427- kfree (inst );
419+ err_free_inst :
420+ cryptd_skcipher_free (inst );
428421 }
429422 return err ;
430423}
@@ -694,8 +687,7 @@ static int cryptd_create_hash(struct crypto_template *tmpl, struct rtattr **tb,
694687 err = ahash_register_instance (tmpl , inst );
695688 if (err ) {
696689err_free_inst :
697- crypto_drop_shash (& ctx -> spawn );
698- kfree (inst );
690+ cryptd_hash_free (inst );
699691 }
700692 return err ;
701693}
@@ -833,17 +825,12 @@ static int cryptd_create_aead(struct crypto_template *tmpl,
833825 struct aead_instance_ctx * ctx ;
834826 struct aead_instance * inst ;
835827 struct aead_alg * alg ;
836- const char * name ;
837828 u32 type = 0 ;
838829 u32 mask = CRYPTO_ALG_ASYNC ;
839830 int err ;
840831
841832 cryptd_check_internal (tb , & type , & mask );
842833
843- name = crypto_attr_alg_name (tb [1 ]);
844- if (IS_ERR (name ))
845- return PTR_ERR (name );
846-
847834 inst = kzalloc (sizeof (* inst ) + sizeof (* ctx ), GFP_KERNEL );
848835 if (!inst )
849836 return - ENOMEM ;
@@ -852,14 +839,14 @@ static int cryptd_create_aead(struct crypto_template *tmpl,
852839 ctx -> queue = queue ;
853840
854841 err = crypto_grab_aead (& ctx -> aead_spawn , aead_crypto_instance (inst ),
855- name , type , mask );
842+ crypto_attr_alg_name ( tb [ 1 ]) , type , mask );
856843 if (err )
857- goto out_free_inst ;
844+ goto err_free_inst ;
858845
859846 alg = crypto_spawn_aead_alg (& ctx -> aead_spawn );
860847 err = cryptd_init_instance (aead_crypto_instance (inst ), & alg -> base );
861848 if (err )
862- goto out_drop_aead ;
849+ goto err_free_inst ;
863850
864851 inst -> alg .base .cra_flags = CRYPTO_ALG_ASYNC |
865852 (alg -> base .cra_flags & CRYPTO_ALG_INTERNAL );
@@ -879,10 +866,8 @@ static int cryptd_create_aead(struct crypto_template *tmpl,
879866
880867 err = aead_register_instance (tmpl , inst );
881868 if (err ) {
882- out_drop_aead :
883- crypto_drop_aead (& ctx -> aead_spawn );
884- out_free_inst :
885- kfree (inst );
869+ err_free_inst :
870+ cryptd_aead_free (inst );
886871 }
887872 return err ;
888873}
0 commit comments