Skip to content

Commit ca94e93

Browse files
ebiggersherbertx
authored andcommitted
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 5e27f38 ("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>
1 parent ff67062 commit ca94e93

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎crypto/algapi.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,10 @@ int crypto_grab_spawn(struct crypto_spawn *spawn, const char *name,
720720
struct crypto_alg *alg;
721721
int err;
722722

723+
/* Allow the result of crypto_attr_alg_name() to be passed directly */
724+
if (IS_ERR(name))
725+
return PTR_ERR(name);
726+
723727
alg = crypto_find_alg(name, spawn->frontend, type, mask);
724728
if (IS_ERR(alg))
725729
return PTR_ERR(alg);

0 commit comments

Comments
 (0)