diff options
author | Ard Biesheuvel <ard.biesheuvel@linaro.org> | 2017-07-21 11:42:37 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2017-08-03 01:52:44 -0400 |
commit | cc4d110ec824d3f05f95b1f705158afc6fb08773 (patch) | |
tree | 8c09c9f195f61aca2f240efc71dd229cf50e38ed | |
parent | 3c08377262880afc1621ab9cb6dbe7df47a6033d (diff) |
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>
-rw-r--r-- | crypto/scompress.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/crypto/scompress.c b/crypto/scompress.c index 0b40d991d65f..2c07648305ad 100644 --- a/crypto/scompress.c +++ b/crypto/scompress.c | |||
@@ -125,8 +125,11 @@ static int crypto_scomp_alloc_all_scratches(void) | |||
125 | if (!scomp_src_scratches) | 125 | if (!scomp_src_scratches) |
126 | return -ENOMEM; | 126 | return -ENOMEM; |
127 | scomp_dst_scratches = crypto_scomp_alloc_scratches(); | 127 | 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; | ||
129 | return -ENOMEM; | 131 | return -ENOMEM; |
132 | } | ||
130 | } | 133 | } |
131 | return 0; | 134 | return 0; |
132 | } | 135 | } |