From: Lasse Collin Date: Mon, 7 Mar 2022 08:06:31 +0000 (+0100) Subject: xz: fix XZ_DYNALLOC to avoid useless memory reallocations X-Git-Tag: archive/raspbian/4.17.0-1+rpi1^2~33^2~857 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=22d5d1c0d18893d9cb92b322f95d7ebab6c0cfd9;p=xen.git xz: fix XZ_DYNALLOC to avoid useless memory reallocations s->dict.allocated was initialized to 0 but never set after a successful allocation, thus the code always thought that the dictionary buffer has to be reallocated. Link: http://lkml.kernel.org/r/20191104185107.3b6330df@tukaani.org Reported-by: Yu Sun Signed-off-by: Lasse Collin Acked-by: Daniel Walker Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Origin: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 8e20ba2e53fc Signed-off-by: Jan Beulich Reviewed-by: Luca Fancellu Acked-by: Andrew Cooper --- diff --git a/xen/common/xz/dec_lzma2.c b/xen/common/xz/dec_lzma2.c index 6b07722e3c..68bcf0f29a 100644 --- a/xen/common/xz/dec_lzma2.c +++ b/xen/common/xz/dec_lzma2.c @@ -1146,6 +1146,7 @@ XZ_EXTERN enum xz_ret __init xz_dec_lzma2_reset(struct xz_dec_lzma2 *s, uint8_t if (DEC_IS_DYNALLOC(s->dict.mode)) { if (s->dict.allocated < s->dict.size) { + s->dict.allocated = s->dict.size; large_free(s->dict.buf); s->dict.buf = large_malloc(s->dict.size); if (s->dict.buf == NULL) {