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

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


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Fri, 19 Nov 2021 11:21:26 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=GS19NKXjFTcuZWiTvSaFRadeqka4sVuIO4lh4DFHodI=; b=gLqI3Lz/XnSKvqwCMngZTdz0yCtsBcIkYt2F7K9Prol//aFssdfA8AgR6lcACNfnDAN7n5XU4lOY/J4H95JZjm9e207DQZJUjPZFzC7aLpK0NkoGlSkmLcL/SRYkvRlhz9L+6Ko4nVghfO5Q+5XeLfiXJs7ex4OBBCmwCqQGOL9QmaKWXWCxK7C6o1bytPlE/ZD6ECojqlo93SejvpA7MB2y88HZXwUw8UjYMtLdmbATHipE8fvH1s2dfoRfiADpm3f0jn3BUofx2rNBZQ0oWEPoYpgRaKUrrPX5TTkApVv9y9GGWqNl+6MEBPeyWT20wJBpTi/ipJ7YnK75p0cfwA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WUXb9tLPbIsfNn140TXGHMGqER8liqGI+RmeDyfAHjDJAppJ2KiTyuuwDAF3CR0mjTgoSnU2KNZaglaJPgJmtgE5DFl4O3TlYSM/M0uxgkugGy1zvQWfhuZ6+iQ/w2xPsi9FObyNcYOV+MZ4e/yRTpWPUpCqOx+Lf2m5N10mrLzbS/uWXkxdeDoJPec5Z9VP+Tj9bS8EvEw6iv87O0e+ax9uzQWsLBVsNA5wOdalzrRw3k4vmkhZDgnThJ8nT4Jr4QWJJESh467y2O5MmOZUC3M8gSJVMu6AVIedVNPz1nX+n5E26m1AgeKmZePJ6f8T7ovCYrhZmvJvC8PLFcd8WQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Fri, 19 Nov 2021 10:21:53 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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




 


Rackspace

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