diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2025-03-15 20:37:36 +0800 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2025-03-21 17:39:05 +0800 |
commit | ddd0a42671c0d9742fda97d26068ffbb51dd7c01 (patch) | |
tree | 8b95eb4431a0e095c6bf1def8dfa3d76de251308 /crypto | |
parent | 7e0969bae493b346e62293d46dd965c545635f52 (diff) |
crypto: scompress - Fix scratch allocation failure handling
If the scratch allocation fails, all subsequent allocations will
silently succeed without actually allocating anything. Fix this
by only incrementing users when the allocation succeeds.
Fixes: 6a8487a1f29f ("crypto: scompress - defer allocation of scratch buffer to first use")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/scompress.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/crypto/scompress.c b/crypto/scompress.c index f85cc0d83164..5e0238af5425 100644 --- a/crypto/scompress.c +++ b/crypto/scompress.c @@ -159,8 +159,12 @@ static int crypto_scomp_init_tfm(struct crypto_tfm *tfm) if (ret) goto unlock; } - if (!scomp_scratch_users++) + if (!scomp_scratch_users) { ret = crypto_scomp_alloc_scratches(); + if (ret) + goto unlock; + scomp_scratch_users++; + } unlock: mutex_unlock(&scomp_lock); |