linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [patch 03/11] lib/xz: fix XZ_DYNALLOC to avoid useless memory reallocations
@ 2019-11-16  1:34 akpm
  0 siblings, 0 replies; only message in thread
From: akpm @ 2019-11-16  1:34 UTC (permalink / raw)
  To: akpm, danielwa, lasse.collin, linux-mm, mm-commits, torvalds,
	yisi, yusun2

From: Lasse Collin <lasse.collin@tukaani.org>
Subject: lib/xz: fix XZ_DYNALLOC to avoid useless memory reallocations

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@tukaani.org
Signed-off-by: Lasse Collin <lasse.collin@tukaani.org>
Reported-by: Yu Sun <yusun2@cisco.com>
Acked-by: Daniel Walker <danielwa@cisco.com>
Cc: "Yixia Si (yisi)" <yisi@cisco.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 lib/xz/xz_dec_lzma2.c |    1 +
 1 file changed, 1 insertion(+)

--- a/lib/xz/xz_dec_lzma2.c~lib-xz-fix-xz_dynalloc-to-avoid-useless-memory-reallocations
+++ a/lib/xz/xz_dec_lzma2.c
@@ -1146,6 +1146,7 @@ XZ_EXTERN enum xz_ret xz_dec_lzma2_reset
 
 		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) {
_


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-11-16  1:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-16  1:34 [patch 03/11] lib/xz: fix XZ_DYNALLOC to avoid useless memory reallocations akpm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox