Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp2976359ybx; Fri, 8 Nov 2019 12:09:16 -0800 (PST) X-Google-Smtp-Source: APXvYqwElamsGiJFRXCFsQqRcrNZ6exrtcuMafYPgLxWEx/dmaqxU8GKvF26qiXU0zRtLaMGN5f8 X-Received: by 2002:a17:906:e297:: with SMTP id gg23mr10767621ejb.41.1573243756112; Fri, 08 Nov 2019 12:09:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573243756; cv=none; d=google.com; s=arc-20160816; b=hLTCgxI5txpV8Ujh9zCjzZJu99eaWrce5qPfTGZ8mh0SoetPz97PCYnG8vMBE3BUT6 UA/4j248csM72uAKltNy5XwDpAwnZibThjfJ+d8fi7rvSwJ3BkRiq9dX/2WVipUA/roB qPpbfSx7cduWsLkOZ2+WkAPV8u5yXY9hBkc3migfSSqrHBOM9qrI2rgyvPs1NrSxEXDp 7iE6QRX3sPys0LCOiJf4026A445UUDNmkbn53JEIUqxsn6daHv8d4FfU4oRupyEb9B9r +K1NqxrDvKRk4fSIwVy0bTagJrmsDYzgz1oXCluh99ab7iizMdnOV2v5NjjinPFjelu+ F2hQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=yaRZIhwFFCjkvMQ6W7kI1FQWSm0XImNmpO4fa5eUTTs=; b=oT1bI2/hdeZIlvTMdWFmq/4iAhHkkaqecAyXoO6PLF2HjF6yfa+eZXwopKFhD8lWiR dAhL6JVP+XP0AuYRZzz9SDysmGTeRC96TbrnmZHSpKYny7UhHEykGNzflayvYnrRnvKR dRIUauj2bnZ6M3Zn4ZuVHVThzHx6SUExqovutc5bLKKTubosSSbLbBa6NjkPBE7N8X4d H2Ly+nmAhxy6IWj7UOllaumcbwQRa6z0zqo/fACjZVPKnjyy8FG4SuU7gUWsykce4eJC 7TQFS8qDkMD8UwkIEwZxuCO+WEzf1pl7wJkjYylR4bzvJIwbeRX2ZMuY29DWAFhA/gN2 me4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cisco.com header.s=iport header.b=E1wEJh8G; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=cisco.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a28si5422461edc.5.2019.11.08.12.08.53; Fri, 08 Nov 2019 12:09:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@cisco.com header.s=iport header.b=E1wEJh8G; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=cisco.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387707AbfKHUHv (ORCPT + 99 others); Fri, 8 Nov 2019 15:07:51 -0500 Received: from alln-iport-2.cisco.com ([173.37.142.89]:4873 "EHLO alln-iport-2.cisco.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731186AbfKHUHs (ORCPT ); Fri, 8 Nov 2019 15:07:48 -0500 X-Greylist: delayed 425 seconds by postgrey-1.27 at vger.kernel.org; Fri, 08 Nov 2019 15:07:46 EST DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=1046; q=dns/txt; s=iport; t=1573243668; x=1574453268; h=from:to:cc:subject:date:message-id; bh=X1lPDJ2u683UXe+m/XoPk0zEHMn31p9nWWtfEQdDTlg=; b=E1wEJh8Gm0pSSYS8eDxmTNOlv4JWWQfel7sfmApGnsiaJgk0bl9nZpwi 6QRQXRMEFJTpaU/axkSrXZ7x70nSP1cF1eUOUmDxUzWHOFcf77xKfQHYU Zsr2eMF89H8Mc6tqwxr4giCyQLOw67WfxJ2omOGZekHj2b91NkHxtWq1T k=; X-IronPort-AV: E=Sophos;i="5.68,283,1569283200"; d="scan'208";a="368687251" Received: from alln-core-11.cisco.com ([173.36.13.133]) by alln-iport-2.cisco.com with ESMTP/TLS/DHE-RSA-SEED-SHA; 08 Nov 2019 20:00:42 +0000 Received: from zorba.cisco.com ([10.24.83.59]) by alln-core-11.cisco.com (8.15.2/8.15.2) with ESMTP id xA8K0eEd022208; Fri, 8 Nov 2019 20:00:41 GMT From: Daniel Walker To: Andrew Morton Cc: Lasse Collin , Yu Sun , xe-linux-external@cisco.com, Daniel Walker , 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 Message-Id: <20191108200040.20259-2-danielwa@cisco.com> X-Mailer: git-send-email 2.17.1 X-Auto-Response-Suppress: DR, OOF, AutoReply X-Outbound-SMTP-Client: 10.24.83.59, [10.24.83.59] X-Outbound-Node: alln-core-11.cisco.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lasse Collin 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 Cc: xe-linux-external@cisco.com Signed-off-by: Daniel Walker --- 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