From: Daniel Walker <danielwa@cisco.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Lasse Collin <lasse.collin@tukaani.org>,
Yu Sun <yusun2@cisco.com>,
xe-linux-external@cisco.com, Daniel Walker <dwalker@fifo99.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] lib/xz: Fix XZ_DYNALLOC to avoid useless memory reallocations.
Date: Fri, 8 Nov 2019 12:00:40 -0800 [thread overview]
Message-ID: <20191108200040.20259-2-danielwa@cisco.com> (raw)
From: Lasse Collin <lasse.collin@tukaani.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@cisco.com>
Cc: xe-linux-external@cisco.com
Signed-off-by: Daniel Walker <dwalker@fifo99.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
next reply other threads:[~2019-11-08 20:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-08 20:00 Daniel Walker [this message]
2019-11-08 20:27 ` [PATCH 2/2] lib/xz: Fix XZ_DYNALLOC to avoid useless memory reallocations Daniel Walker
2019-11-08 20:50 ` Andrew Morton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191108200040.20259-2-danielwa@cisco.com \
--to=danielwa@cisco.com \
--cc=akpm@linux-foundation.org \
--cc=dwalker@fifo99.com \
--cc=lasse.collin@tukaani.org \
--cc=linux-kernel@vger.kernel.org \
--cc=xe-linux-external@cisco.com \
--cc=yusun2@cisco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).