Skip to content

Commit ddd0a42

Browse files
committed
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: 6a8487a ("crypto: scompress - defer allocation of scratch buffer to first use") Signed-off-by: Herbert Xu <[email protected]> Acked-by: Ard Biesheuvel <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 7e0969b commit ddd0a42

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

crypto/scompress.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,12 @@ static int crypto_scomp_init_tfm(struct crypto_tfm *tfm)
159159
if (ret)
160160
goto unlock;
161161
}
162-
if (!scomp_scratch_users++)
162+
if (!scomp_scratch_users) {
163163
ret = crypto_scomp_alloc_scratches();
164+
if (ret)
165+
goto unlock;
166+
scomp_scratch_users++;
167+
}
164168
unlock:
165169
mutex_unlock(&scomp_lock);
166170

0 commit comments

Comments
 (0)