crypto: skcipher - use crypto_grab_cipher() and simplify error paths

Make skcipher_alloc_instance_simple() use the new function
crypto_grab_cipher() to initialize its cipher spawn.

This is needed to make all spawns be initialized in a consistent way.

Also simplify the error handling by taking advantage of crypto_drop_*()
now accepting (as a no-op) spawns that haven't been initialized yet, and
by taking advantage of crypto_grab_*() now handling ERR_PTR() names.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
Eric Biggers
2020-01-02 19:59:00 -08:00
committed by Herbert Xu
parent c282586fc3
commit aacd5b4cfb
2 changed files with 17 additions and 26 deletions

View File

@@ -214,9 +214,9 @@ struct skcipher_instance *skcipher_alloc_instance_simple(
static inline struct crypto_alg *skcipher_ialg_simple(
struct skcipher_instance *inst)
{
struct crypto_spawn *spawn = skcipher_instance_ctx(inst);
struct crypto_cipher_spawn *spawn = skcipher_instance_ctx(inst);
return spawn->alg;
return crypto_spawn_cipher_alg(spawn);
}
#endif /* _CRYPTO_INTERNAL_SKCIPHER_H */