From b3c16bfc6a79ae517ec3c44be615aed0ffa52c53 Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Fri, 20 Dec 2019 13:29:40 +0800 Subject: crypto: skcipher - Add skcipher_ialg_simple helper This patch introduces the skcipher_ialg_simple helper which fetches the crypto_alg structure from a simple skcipher instance's spawn. This allows us to remove the third argument from the function skcipher_alloc_instance_simple. In doing so the reference count to the algorithm is now maintained by the Crypto API and the caller no longer needs to drop the alg refcount. Signed-off-by: Herbert Xu --- crypto/skcipher.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'crypto/skcipher.c') diff --git a/crypto/skcipher.c b/crypto/skcipher.c index 39a718d99220..37adb71f7759 100644 --- a/crypto/skcipher.c +++ b/crypto/skcipher.c @@ -938,15 +938,12 @@ static void skcipher_free_instance_simple(struct skcipher_instance *inst) * * @tmpl: the template being instantiated * @tb: the template parameters - * @cipher_alg_ret: on success, a pointer to the underlying cipher algorithm is - * returned here. It must be dropped with crypto_mod_put(). * * Return: a pointer to the new instance, or an ERR_PTR(). The caller still * needs to register the instance. */ -struct skcipher_instance * -skcipher_alloc_instance_simple(struct crypto_template *tmpl, struct rtattr **tb, - struct crypto_alg **cipher_alg_ret) +struct skcipher_instance *skcipher_alloc_instance_simple( + struct crypto_template *tmpl, struct rtattr **tb) { struct crypto_attr_type *algt; struct crypto_alg *cipher_alg; @@ -982,6 +979,7 @@ skcipher_alloc_instance_simple(struct crypto_template *tmpl, struct rtattr **tb, if (err) goto err_free_inst; + spawn->dropref = true; err = crypto_init_spawn(spawn, cipher_alg, skcipher_crypto_instance(inst), CRYPTO_ALG_TYPE_MASK); @@ -1003,7 +1001,6 @@ skcipher_alloc_instance_simple(struct crypto_template *tmpl, struct rtattr **tb, inst->alg.init = skcipher_init_tfm_simple; inst->alg.exit = skcipher_exit_tfm_simple; - *cipher_alg_ret = cipher_alg; return inst; err_free_inst: -- cgit v1.2.3