Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3676582pxv; Mon, 26 Jul 2021 09:12:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxUxWpnpuNV06I77j62K+IXomkLi5ug7U4G0u6UxLTXLPSVHsKbm9ZXNgRgfJSHZn67Ly3Z X-Received: by 2002:a05:6638:1350:: with SMTP id u16mr17141679jad.19.1627315923329; Mon, 26 Jul 2021 09:12:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627315923; cv=none; d=google.com; s=arc-20160816; b=edQFG0d/t16YGH3VF87E7OM3A+DbC0D9CbajBjWXG70minkl2o72fIkndictgSknK8 a7DkJWRixzmm8puWGALjWGfr3xQ2LuhhZh+tvqsLXUgj9FKepyM53yUGtzBfucxRlv4u yR1DKbDnezkZ54OuVgOuNDcTi69Bs1FgfhD0sj1FYIqSPoGOHUFUzdSSD02NW1Fln3em ynLp11T6qoIUWe+20AERDQUhrmJYyDgg/CGkIXEH4SyA27CnMepLSaWi8axfO09ZiunK /SUYkkjwl0HmF+30jbFlMW5juBLhv796E4UpD/1p+zIFe4kIeCl7ywdR3kAgmXOzmpsn NShw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hQ1KvIldwJ/h6M6EwSJSjAhurKBR7GCgvHM+c1ZGTGo=; b=y/Kg5tLDchSOV9bjMxYXly8TqNT9Ws85npcrwu4dJWew8Ch/twiuqqKINkl85/+Y1Q WXuWn7KNWOOFRe+e8fGI4K2yJtTLK05fPaeXFovmumeCquEW3vhYP8iLx6PLARd92fjM iCsnT22L/cBo6Abo5kfU/+CM/6+KnEmi3zRNKgoxaGSh2Iy5Yg1bymdnMhUqj8zzBVcq BmUxmiMIIRtQ44mCFcphvnjQNHEVjwy7/kfqM8lk1D6Di07q5Vmrlq9yoIFqek7apC+r hGE37T8Kjgb/+N1zjl5KpE8KgWDQ68HydV2imWKxZk434adi9wTeBr/tCAs8FahJfFnn 9iwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Jr+AnWZY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n12si273498ilq.134.2021.07.26.09.11.51; Mon, 26 Jul 2021 09:12:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Jr+AnWZY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237717AbhGZP3V (ORCPT + 99 others); Mon, 26 Jul 2021 11:29:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:56760 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235438AbhGZPQv (ORCPT ); Mon, 26 Jul 2021 11:16:51 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4128560FD8; Mon, 26 Jul 2021 15:57:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627315039; bh=jnwL9oSy03Knv9wzFjNz98XWr/TQv4RU3bqPVP0kbDo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jr+AnWZY9jM+ETGDYWxt82ONjNMKwslJdK4yLMEZgfm4zBq8rPnWEqR+QQVEte/V6 THGjKxFmjdApG/6OO7MqzTY7uJDDVFQ42yM5mGWjPbYUHwg2NVtSEHm+58E4WUqNzg XT+cM9bDesRbPQUEQyB4XyHAoJ0vKziXIgrNxVlY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Riccardo Mancini , Ian Rogers , Jiri Olsa , Mark Rutland , Namhyung Kim , Peter Zijlstra , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 5.4 027/108] perf lzma: Close lzma stream on exit Date: Mon, 26 Jul 2021 17:38:28 +0200 Message-Id: <20210726153832.571578765@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153831.696295003@linuxfoundation.org> References: <20210726153831.696295003@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Riccardo Mancini [ Upstream commit f8cbb0f926ae1e1fb5f9e51614e5437560ed4039 ] ASan reports memory leaks when running: # perf test "88: Check open filename arg using perf trace + vfs_getname" One of these is caused by the lzma stream never being closed inside lzma_decompress_to_file(). This patch adds the missing lzma_end(). Signed-off-by: Riccardo Mancini Fixes: 80a32e5b498a7547 ("perf tools: Add lzma decompression support for kernel module") Cc: Ian Rogers Cc: Jiri Olsa Cc: Mark Rutland Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lore.kernel.org/lkml/aaf50bdce7afe996cfc06e1bbb36e4a2a9b9db93.1626343282.git.rickyman7@gmail.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/util/lzma.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/lzma.c b/tools/perf/util/lzma.c index 39062df02629..51424cdc3b68 100644 --- a/tools/perf/util/lzma.c +++ b/tools/perf/util/lzma.c @@ -69,7 +69,7 @@ int lzma_decompress_to_file(const char *input, int output_fd) if (ferror(infile)) { pr_err("lzma: read error: %s\n", strerror(errno)); - goto err_fclose; + goto err_lzma_end; } if (feof(infile)) @@ -83,7 +83,7 @@ int lzma_decompress_to_file(const char *input, int output_fd) if (writen(output_fd, buf_out, write_size) != write_size) { pr_err("lzma: write error: %s\n", strerror(errno)); - goto err_fclose; + goto err_lzma_end; } strm.next_out = buf_out; @@ -95,11 +95,13 @@ int lzma_decompress_to_file(const char *input, int output_fd) break; pr_err("lzma: failed %s\n", lzma_strerror(ret)); - goto err_fclose; + goto err_lzma_end; } } err = 0; +err_lzma_end: + lzma_end(&strm); err_fclose: fclose(infile); return err; -- 2.30.2