Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3681186pxv; Mon, 26 Jul 2021 09:16:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTqlZf1gyHoTMLnCtqOydKIianEhWDai0Gz5DUL0zHcR4XYUs16uy1ItkgHuCb8Fusms2E X-Received: by 2002:a05:6638:3291:: with SMTP id f17mr17281770jav.143.1627316182385; Mon, 26 Jul 2021 09:16:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627316182; cv=none; d=google.com; s=arc-20160816; b=y4Blr4CsyjYkQtHIOeZN5Z5ITaWPx36seBw5f17CIMe1FVQxDUn8m8i72CaCPHoxQ7 XDDijKoNefRUcl8zfHiQ/g9wZmtRfc9gj35D4H+qbmAlGHeJ8HJBabQG8rQyLgohkbFm +SN++C7nCkOKse9CEEFwT++uiRC0DY00+yif14f9xNdARsW+Fi58mmjqyfFO/PAwaQwc CzUNbaVXB3WZ4Itl3TsEqXvZ2ffZfZ8BSWiNhrpdxcNBBQAixjR2lbnsZlC1ZPM11TZI Dx1KaX3w6q+yhRJC6BiVBah5GpHy9K1y91KNqzyLGgvZSlrWV7+4NvDLk+wZd2v60jOv J+iQ== 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=eijoOpuUwX3QAX6874P8QAKB6RuZF8Mx1NBr8Bud5jo=; b=QRTNGPqF2ndcl7wy1AxIDXzBb1QIRcN4Dx5GnWru0PcRxGgcCfO+Ka6OyHN8oTO8A0 BN+veJiRH2gdcuxEEL9CM8HDviJ0l9yqlhM1/FNmZsEqXA0u9GOBTMdfFvjWoUZ39R8K sFaQ8w5fBrfRX14Ip9sbIniH5rgvhKu0rLGIUx04HAjWqrnsnYNQ0v8V6kCrEZmxj1pp Q/4SrnrNdPBirt2nlC5M1lhZEgc3VfCu/FQR3Qub1NPH68G4IIpeTQouyVvLW8NGAuZL 5whfeememezH7By64CSC3nbOZ55oDdsSVgJ6KU4MXEfGyum8ITu1fsG+wNbaqeNoIEUG gaHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WsvvblNs; 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 a16si261310ilb.149.2021.07.26.09.16.09; Mon, 26 Jul 2021 09:16:22 -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=WsvvblNs; 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 S234945AbhGZPeD (ORCPT + 99 others); Mon, 26 Jul 2021 11:34:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:60334 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236616AbhGZPTT (ORCPT ); Mon, 26 Jul 2021 11:19:19 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 04E1360FD7; Mon, 26 Jul 2021 15:59:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627315187; bh=npH5eqlpatA98/12plTXrBIf/CfD70hux0lUZ+i+ESw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WsvvblNsirSoGpcjUeZEBFSP3S/2f6alv3jCZaFIFNoJ1aMP/pqC9blI9MOGL1APZ kIaSRO3+20erMcuAl+JaSEWofF4p2XxLM+/yqwVBdXwTUYE8LpJRq81yFMphn+IrVs mCBcK/dsJhdnlwzMn39qgDpwPcUauRtR9d7R/CcU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Riccardo Mancini , Ian Rogers , Jiri Olsa , Mamatha Inamdar , Mark Rutland , Namhyung Kim , Peter Zijlstra , Arnaldo Carvalho de Melo Subject: [PATCH 5.4 107/108] perf inject: Close inject.output on exit Date: Mon, 26 Jul 2021 17:39:48 +0200 Message-Id: <20210726153835.103060624@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 commit 02e6246f5364d5260a6ea6f92ab6f409058b162f upstream. ASan reports a memory leak when running: # perf test "83: Zstd perf.data compression/decompression" which happens inside 'perf inject'. The bug is caused by inject.output never being closed. This patch adds the missing perf_data__close(). Signed-off-by: Riccardo Mancini Fixes: 6ef81c55a2b6584c ("perf session: Return error code for perf_session__new() function on failure") Cc: Ian Rogers Cc: Jiri Olsa Cc: Mamatha Inamdar Cc: Mark Rutland Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lore.kernel.org/lkml/c06f682afa964687367cf6e92a64ceb49aec76a5.1626343282.git.rickyman7@gmail.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Greg Kroah-Hartman --- tools/perf/builtin-inject.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c @@ -836,8 +836,10 @@ int cmd_inject(int argc, const char **ar data.path = inject.input_name; inject.session = perf_session__new(&data, inject.output.is_pipe, &inject.tool); - if (IS_ERR(inject.session)) - return PTR_ERR(inject.session); + if (IS_ERR(inject.session)) { + ret = PTR_ERR(inject.session); + goto out_close_output; + } if (zstd_init(&(inject.session->zstd_data), 0) < 0) pr_warning("Decompression initialization failed.\n"); @@ -874,5 +876,7 @@ int cmd_inject(int argc, const char **ar out_delete: zstd_fini(&(inject.session->zstd_data)); perf_session__delete(inject.session); +out_close_output: + perf_data__close(&inject.output); return ret; }