[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/7] xz: fix XZ_DYNALLOC to avoid useless memory reallocations



Hi Jan,

On 19/11/2021 10:21, Jan Beulich wrote:
From: Lasse Collin <lasse.collin@xxxxxxxxxxx>

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@xxxxxxxxxxx
Reported-by: Yu Sun <yusun2@xxxxxxxxx>
Signed-off-by: Lasse Collin <lasse.collin@xxxxxxxxxxx>
Acked-by: Daniel Walker <danielwa@xxxxxxxxx>
[Linux commit: 8e20ba2e53fc6198cbfbcc700e9f884157052a8d]

This commit contains two more signed-off-by. Any reason to not have included them here?

The rest of the patch LGTM.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

--- 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_lzma
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) {


Cheers,

--
Julien Grall



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.