From: Ard Biesheuvel Date: Fri, 21 Jul 2017 15:42:37 +0000 (+0100) Subject: crypto: scompress - free partially allocated scratch buffers on failure X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=cc4d110ec824d3f05f95b1f705158afc6fb08773;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git 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 Signed-off-by: Herbert Xu --- 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) 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; }