Skip to content

Commit

Permalink
crypto: scompress - free partially allocated scratch buffers on failure
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
Ard Biesheuvel authored and herbertx committed Aug 3, 2017
1 parent 3c08377 commit cc4d110
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion crypto/scompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit cc4d110

Please sign in to comment.