diff options
author | Eric Biggers <ebiggers@google.com> | 2020-01-02 19:58:42 -0800 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2020-01-09 11:30:53 +0800 |
commit | 9e84b19eaf25c6f394d08323ed779e98eb9c029d (patch) | |
tree | a8f9fbb61a6539998d3e8e8813e4047e451ffa9d /crypto/algapi.c | |
parent | e7d96e1eba38ccf867353d058e16738cdc226ced (diff) | |
download | linux-crypto-9e84b19eaf25c6f394d08323ed779e98eb9c029d.tar.gz linux-crypto-9e84b19eaf25c6f394d08323ed779e98eb9c029d.zip |
crypto: algapi - make crypto_grab_spawn() handle an ERR_PTR() name
To allow further simplifying template ->create() functions, make
crypto_grab_spawn() handle an ERR_PTR() name by passing back the error.
For most templates, this will allow the result of crypto_attr_alg_name()
to be passed directly to crypto_grab_*(), rather than first having to
assign it to a variable [where it can then potentially be misused, as it
was in the rfc7539 template prior to commit 2b169ef4349a ("crypto:
chacha20poly1305 - set cra_name correctly")] and check it for error.
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/algapi.c')
-rw-r--r-- | crypto/algapi.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/crypto/algapi.c b/crypto/algapi.c index 4c761f48..a5223c5f 100644 --- a/crypto/algapi.c +++ b/crypto/algapi.c @@ -720,6 +720,10 @@ int crypto_grab_spawn(struct crypto_spawn *spawn, const char *name, struct crypto_alg *alg; int err; + /* Allow the result of crypto_attr_alg_name() to be passed directly */ + if (IS_ERR(name)) + return PTR_ERR(name); + alg = crypto_find_alg(name, spawn->frontend, type, mask); if (IS_ERR(alg)) return PTR_ERR(alg); |