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

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


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 3 Mar 2022 11:05:17 +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=A25zh5BjjDRbl+SbPOMZedHC8tdiYgioJS38R9kRtSE=; b=JleOcDtZ6i8zfGK82DZSp/Kh+JZin+gliWqD4zGavMJ4e2uirvd6yRmJ/jSYFwakY4+rBDEmwE4t/A5U6zwsw381I09FgSZGqa0drxEVHLiA+2ourk8Q7dfTPD7U7C1A3Py85x9aiCFwEJxCkRfSE4m1YvBsOSAXtFbv909NvBO0Kkjv2bDTv79Ep/WSbiy/W+8ZHuJW5AP90mGMrG+ut1gssFu6b8fudE+R08H2TUysqUL+w1nMl+gk12PijS+UsWu6gCbEDvghpwyvXMZStkHxuhp3/L3MEUhzbjOPU5L/o/K2v0WO14U/+GrNrAe1lry4Rui+tjBXl1bipPXjNg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BFbfilM322kOSYz/nQ7WXY94r11oTuVP/kEs0dxhSFUov+pxwEU9/v4Ov287wRfSX5j0pd5qu923K5ZlxjXN2l8KuuQrcfXMzHQ9dLQxEEMKmXX6cI3SfZc8Evg9McapynvozQu3144xxKioKZWGvI59983CaGdychJY9V4i8xYgoPe7/Oa1Lr8mtOzZ8yMtYwBcXF1sZbDCSN5GxHMhWjDC0vSHsBxXxFscvAgHJUstfcek2R7qC6UPrhXRg8dUSYc8n+aIn6UvbAy+HelGjFNrHEORCoQuI2C59w/zcXe/6ovby29ru+jJNgSGo3I0zF0F8vFYiopKHP4dubDZpg==
  • 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>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Thu, 03 Mar 2022 10:05:26 +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>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Signed-off-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
[Linux commit: 8e20ba2e53fc6198cbfbcc700e9f884157052a8d]
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Reviewed-by: Luca Fancellu <luca.fancellu@xxxxxxx>
---
v3: Retain all Linux side S-o-b, as per 5e326b61693c.

--- 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®.