Skip to content

Commit

Permalink
crypto: scompress - Fix scratch allocation failure handling
Browse files Browse the repository at this point in the history
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: 6a8487a ("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>
  • Loading branch information
Herbert Xu committed Mar 21, 2025
1 parent 7e0969b commit ddd0a42
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion crypto/scompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit ddd0a42

Please sign in to comment.