[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 2/7] xz: fix XZ_DYNALLOC to avoid useless memory reallocations
- To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Jan Beulich <jbeulich@xxxxxxxx>
- Date: Mon, 6 Dec 2021 14:31:13 +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=NCSQ+AXXRTjdtJyeP2akK62GyR4QHv+YZ2pLR/0+MYY=; b=g48RbDNF3lnvgZuKyy30myXG1eODG+qfVC2IkR38+ApkVofWlP4KNmRzVZCuU0gSgV3iWpsUx/i6jmyYvRpJciBvmhxyCgNDnAdXUgUyag0hTARMGbsLreHIx01YPHkuFJSQrMSzhkQL0xb35FGRMsR+p8VKhhStmaVSZNDTGVpvi2h6SeK3ISIhyMOB0rS6SSBPZXSAw/20S6xjpT39EdTKBDbDtFos84pk764Y+22hMh3TNAoqad/fxcZFR/AgoHlzuClBWuXlGNSppj34DnvwbDKEL6jQsf8GKcj0CGLCv4bQ4njYopnbaaUCRTbgN5fg41q75hhDuHE5qGiLug==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YXD/pMNJm4DdDLSYKHPhETw1V5AUWHQkHOyd1x7mmvyAbmqBaKt/bbBDF2Sfx1pwgW5PlklwXnbR7Hefaf0XZjeOceUmCxTPfImxs89dLm/WRDJNtLYiGAO5616Llkl9WgDW+T7Gal/C+QR8UACAjlhsdeBKP+ur+Btr+jtFo2wyCov5SPoG0K+ODyVzewGVqQYCNsp0LkUeL5ttLc9N+AVbQSVRSfyWnxCL4CXYEP9YVsEs0+f8Xeef5v1MZgq5vVBx39kFMaLJkAtXZz8HYmYvc/FZxYBQWqj7PgDTM6veHJgLgNe4K/aHa1znbKmuDLjtzpCHmr95pDRVjkhxCw==
- 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: Mon, 06 Dec 2021 13:31:25 +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>
Reviewed-by: Luca Fancellu <luca.fancellu@xxxxxxx>
--- 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) {
|