From: Eric Biggers <ebiggers@kernel.org>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Linux Crypto Mailing List <linux-crypto@vger.kernel.org>
Subject: Re: [PATCH] crypto: skcipher - Add skcipher_ialg_simple helper
Date: Fri, 6 Dec 2019 13:47:43 -0800 [thread overview]
Message-ID: <20191206214742.GA246840@gmail.com> (raw)
In-Reply-To: <20191206055704.g2g5y2e5dakxj7za@gondor.apana.org.au>
On Fri, Dec 06, 2019 at 01:57:04PM +0800, Herbert Xu wrote:
> This patch introduces the skcipher_ialg_simple helper which fetches
> the crypto_alg structure from a simple skcpiher instance's spawn.
>
> This allows us to remove the third argument from the function
> skcipher_alloc_instance_simple.
>
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
>
> diff --git a/crypto/cbc.c b/crypto/cbc.c
> index dd96bcf4d4b6..b9c718fe9d7d 100644
> --- a/crypto/cbc.c
> +++ b/crypto/cbc.c
> @@ -54,10 +54,12 @@ static int crypto_cbc_create(struct crypto_template *tmpl, struct rtattr **tb)
> struct crypto_alg *alg;
> int err;
>
> - inst = skcipher_alloc_instance_simple(tmpl, tb, &alg);
> + inst = skcipher_alloc_instance_simple(tmpl, tb);
> if (IS_ERR(inst))
> return PTR_ERR(inst);
>
> + alg = skcipher_ialg_simple(inst);
> +
> err = -EINVAL;
> if (!is_power_of_2(alg->cra_blocksize))
> goto out_free_inst;
This doesn't seem like an improvement, because skcipher_alloc_instance_simple()
takes a reference to 'alg' which the caller must drop. It's better to make this
explicit by having 'alg' be one of the return values.
- Eric
next prev parent reply other threads:[~2019-12-06 21:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-06 5:57 [PATCH] crypto: skcipher - Add skcipher_ialg_simple helper Herbert Xu
2019-12-06 21:47 ` Eric Biggers [this message]
2019-12-18 8:07 ` [v2 PATCH] " Herbert Xu
2019-12-19 20:34 ` Eric Biggers
2019-12-20 5:29 ` [v3 " Herbert Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191206214742.GA246840@gmail.com \
--to=ebiggers@kernel.org \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.