Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3698406pxv; Mon, 26 Jul 2021 09:39:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwGtQsB8dAp8Dp+fcTp18+am1IZsivy4ubxeLIwdMjYX/3Rx3Py5z2UoV5jZuhptGKDonjW X-Received: by 2002:a05:6402:430b:: with SMTP id m11mr3363054edc.55.1627317586050; Mon, 26 Jul 2021 09:39:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627317586; cv=none; d=google.com; s=arc-20160816; b=p6MoUAfp/5N/ViGj177rz9/T+hF0P7lHbG8d5yRSJd7PmmRdE1CkzVWPz8I7VK9G5q +zwxTEeSa82hsVUZF8Q3r1D2nyYrhMUNxFkW/zbVW3G+fBPUnpQYDIh4tcEck3cm52yW aU6BXz6JOYrORWz5GY5aQUWLnkqrnx9GGnf4NN5eEVKO1o7RjxzQBG1VeMIr7yXNBI7x apMix5qW3HWOPz61Ulbd0u3BJ433LWRSgqx/x6uYBTei2acgjguGy24+FwjnUwjhccdz txhKclTQXeNMBeqMa7KFaRrdgIy6y8KYARgooC3kKf2S+BYzUNl5OHmZkAgf+aJQdhjC jK/A== 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=IuUTAL/+egYzGIQLM56THveZIVkMOrS/00jGibu9pWg=; b=LPR/2YerxpczuF5KIO4XVkqCDEP/bQDKys9U97n8nMXEbksIkents3Ik4zR2F+eefz /SZNDkK9SnI2cgoG8/B4MqSvg5Y2XQWNwnENyq4bOo/YAdS2wmYMyLF7RkTsSNv4SLUt 9M+DVvG4hCg4SG4868eMl1ABT+B/dFJ+a7n/JfZB1v4Zq+ctMHLrUSTg6DUYXLjZSDjE wJnpkenScVWtdV5uySBS+yafvXcEe56+xyvMNcPRo1/ozN8Cybwwg/L6Sf7N+riwt++x PhdKlDi5pHCzs4E4YsWORXJWhRZumMEVvR3xuVbvUvWtcGEqU9JfKnBsCz4VnMUL2i0q NdLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dOlC64V6; 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 a2si505282edk.106.2021.07.26.09.39.23; Mon, 26 Jul 2021 09:39:46 -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=dOlC64V6; 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 S237962AbhGZP5f (ORCPT + 99 others); Mon, 26 Jul 2021 11:57:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:54714 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234567AbhGZPgV (ORCPT ); Mon, 26 Jul 2021 11:36:21 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 62E9A6056B; Mon, 26 Jul 2021 16:16:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627316208; bh=8yoIR8LLU75X/UR5tHCqsP+hO1yT6Os7kGJkLgWgUNw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dOlC64V6lWYhuCa36LiefndYGvOeHkXzJHb6d/YC2MfzHyIcOb8dMo9l1UM4CSxFe isdUVdAxsNl8AN5rWRHA228vZgdmpk+KXSYHkq1423fHNeAq1rFXC2eqht2hWtoNCu goV8zLtEkoIWfVudY8X3winjeUcTWg0f8sCvyCU0= 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.13 220/223] perf inject: Close inject.output on exit Date: Mon, 26 Jul 2021 17:40:12 +0200 Message-Id: <20210726153853.374553792@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153846.245305071@linuxfoundation.org> References: <20210726153846.245305071@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 @@ -908,8 +908,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"); @@ -951,5 +953,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; }