]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
crypto: scompress - free partially allocated scratch buffers on failure
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Fri, 21 Jul 2017 15:42:37 +0000 (16:42 +0100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 3 Aug 2017 05:52:44 +0000 (13:52 +0800)
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>
crypto/scompress.c

index 0b40d991d65f6f8c65a4d1a7914aa981b2b35ed4..2c07648305adc6823e7caaf28acca72416d4a89c 100644 (file)
@@ -125,8 +125,11 @@ static int crypto_scomp_alloc_all_scratches(void)
                if (!scomp_src_scratches)
                        return -ENOMEM;
                scomp_dst_scratches = crypto_scomp_alloc_scratches();
-               if (!scomp_dst_scratches)
+               if (!scomp_dst_scratches) {
+                       crypto_scomp_free_scratches(scomp_src_scratches);
+                       scomp_src_scratches = NULL;
                        return -ENOMEM;
+               }
        }
        return 0;
 }