[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20191108200040.20259-2-danielwa@cisco.com>
Date: Fri, 8 Nov 2019 12:00:40 -0800
From: Daniel Walker <danielwa@...co.com>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: Lasse Collin <lasse.collin@...aani.org>, Yu Sun <yusun2@...co.com>,
xe-linux-external@...co.com, Daniel Walker <dwalker@...o99.com>,
linux-kernel@...r.kernel.org
Subject: [PATCH 2/2] lib/xz: Fix XZ_DYNALLOC to avoid useless memory reallocations.
From: Lasse Collin <lasse.collin@...aani.org>
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.
For the original commit to xz-embedded.git, please refer to:
https://git.tukaani.org/?p=xz-embedded.git;a=commit;h=40d291b
Signed-off-by: Yu Sun <yusun2@...co.com>
Cc: xe-linux-external@...co.com
Signed-off-by: Daniel Walker <dwalker@...o99.com>
---
lib/xz/xz_dec_lzma2.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/xz/xz_dec_lzma2.c b/lib/xz/xz_dec_lzma2.c
index 08c3c8049998..156f26fdc4c9 100644
--- a/lib/xz/xz_dec_lzma2.c
+++ b/lib/xz/xz_dec_lzma2.c
@@ -1146,6 +1146,7 @@ XZ_EXTERN enum xz_ret xz_dec_lzma2_reset(struct xz_dec_lzma2 *s, uint8_t props)
if (DEC_IS_DYNALLOC(s->dict.mode)) {
if (s->dict.allocated < s->dict.size) {
+ s->dict.allocated = s->dict.size;
vfree(s->dict.buf);
s->dict.buf = vmalloc(s->dict.size);
if (s->dict.buf == NULL) {
--
2.17.1
Powered by blists - more mailing lists