Skip to content

Commit cc4d110

Browse files
Ard Biesheuvelherbertx
Ard Biesheuvel
authored andcommitted
crypto: scompress - free partially allocated scratch buffers on failure
When allocating the per-CPU scratch buffers, we allocate the source and destination buffers separately, but bail immediately if the second allocation fails, without freeing the first one. Fix that. Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 3c08377 commit cc4d110

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

crypto/scompress.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,11 @@ static int crypto_scomp_alloc_all_scratches(void)
125125
if (!scomp_src_scratches)
126126
return -ENOMEM;
127127
scomp_dst_scratches = crypto_scomp_alloc_scratches();
128-
if (!scomp_dst_scratches)
128+
if (!scomp_dst_scratches) {
129+
crypto_scomp_free_scratches(scomp_src_scratches);
130+
scomp_src_scratches = NULL;
129131
return -ENOMEM;
132+
}
130133
}
131134
return 0;
132135
}

0 commit comments

Comments
 (0)