Commit b346e492 authored by Eric Biggers's avatar Eric Biggers Committed by Herbert Xu

crypto: api - fix finding algorithm currently being tested

Commit eb02c38f ("crypto: api - Keep failed instances alive") is
making allocating crypto transforms sometimes fail with ELIBBAD, when
multiple processes try to access encrypted files with fscrypt for the
first time since boot.  The problem is that the "request larval" for the
algorithm is being mistaken for an algorithm which failed its tests.

Fix it by only returning ELIBBAD for "non-larval" algorithms.  Also
don't leak a reference to the algorithm.

Fixes: eb02c38f ("crypto: api - Keep failed instances alive")
Signed-off-by: default avatarEric Biggers <>
Signed-off-by: default avatarHerbert Xu <>
parent 60cc43fc
......@@ -204,9 +204,14 @@ static struct crypto_alg *crypto_alg_lookup(const char *name, u32 type,
alg = __crypto_alg_lookup(name, type | test, mask | test);
if (!alg && test)
alg = __crypto_alg_lookup(name, type, mask) ?
if (!alg && test) {
alg = __crypto_alg_lookup(name, type, mask);
if (alg && !crypto_is_larval(alg)) {
/* Test failed */
return alg;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment