Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cc4d110e authored by Ard Biesheuvel's avatar Ard Biesheuvel Committed by Herbert Xu
Browse files

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: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 3c083772
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -125,9 +125,12 @@ 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;
}