Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3488726imu; Sun, 11 Nov 2018 16:14:32 -0800 (PST) X-Google-Smtp-Source: AJdET5dAu/CRKZlUPJoQVksd/a6DDNULV5loJTYthD95rYgyUvZ2CM0nw2qbzV0UZQmaoy0cqjbU X-Received: by 2002:a63:6dc8:: with SMTP id i191mr15175695pgc.215.1541981672828; Sun, 11 Nov 2018 16:14:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541981672; cv=none; d=google.com; s=arc-20160816; b=ZEGFObdAV9cASpRqlUuHf3f5Z/KQIb9duWj31bJBOeGalswhY1JpIAQI3OdGIdPBP8 EwwyABnDgWjiI3lMvS3xYgoKpG0zvPtUSi9MYZ5wLbOMLbtUbC6bxr8axrlD/10dv0B9 XWXQsw+iRJXKsm4BFLz35yaE8W7wWqX309ZZSAFhLkbcB7GtZdejF3qyW8oKupotOLw+ agXelj+LCch0oP7uLiNEBR7+PtyRKFsvHsND7EXn5pG9WDcQzBlP/VtVDn5Urw4B5OoK T53bsc0XaeY1xZgl2FAplUa3FrblgSHCFrqLZeDbp+Qkrw98pIlUAkX7jDlVCmhzx6Bv UeOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=y9iuaVD0hQ5lWP7oo+tcnQHfqHLoRsKMl3qXEvxnm6Q=; b=qQ9nZU5gwKvAJA2tyQS4XOdfM2qSZrmGbPiIY4xw1/1Ffw+BA8Xb6OT6L+G6lt75N3 SuIxwiMornm4RRLgimvneatgrTlseiI9g7mzbNvb8k7N4zuY86ba1MFa0nUTlTN2MP4p DH7/XNTy72iQcFQDnp6oVoYNsfASlAbdPsAjxuBiFI9xih9jovAPLb7rgKToj/q87wW/ RmwPQ63UqMUVPog7/5ZMDsSoLdULOgwFJowmt/jkCUWZPKRu2dnMTuC1W5NzOCj3wjSr xVAYFeM4suAkhPJWXIS6Rfw92jdIk67zwO0saktmEO/DvPH6Kir1ll069ya0CbG0cDPw FMjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nGBHkr01; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i5-v6si14285619pgg.559.2018.11.11.16.14.17; Sun, 11 Nov 2018 16:14:32 -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=@kernel.org header.s=default header.b=nGBHkr01; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730465AbeKLIRO (ORCPT + 99 others); Mon, 12 Nov 2018 03:17:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:59904 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730385AbeKLIRM (ORCPT ); Mon, 12 Nov 2018 03:17:12 -0500 Received: from localhost (unknown [206.108.79.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C358822360; Sun, 11 Nov 2018 22:27:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975236; bh=f7w3+nhQ+Qej20sdfk3aJK11Qu8ITb62n/evBk6NnGw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nGBHkr01kxd8p0/0taAaJMjgVoeIurTpQy8+WlS1H7k/QP3BS8ch3Hla2yulV2ZkH HcY+JQitjWnp/+C+GRhW+zTw1JGamuNuVJWf45VHq6Ao2zdLcw7WtXgmv4QtWtjkoS Ufo8iQUnxM7lblu4NrXSFGtb4pDpTCXTLAjh8mBw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sanskriti Sharma , Jiri Olsa , Joe Lawrence , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 4.19 064/361] perf tools: Free temporary sys string in read_event_files() Date: Sun, 11 Nov 2018 14:16:51 -0800 Message-Id: <20181111221628.993199504@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sanskriti Sharma [ Upstream commit 1e44224fb0528b4c0cc176bde2bb31e9127eb14b ] For each system in a given pevent, read_event_files() reads in a temporary 'sys' string. Be sure to free this string before moving onto to the next system and/or leaving read_event_files(). Fixes the following coverity complaints: Error: RESOURCE_LEAK (CWE-772): tools/perf/util/trace-event-read.c:343: overwrite_var: Overwriting "sys" in "sys = read_string()" leaks the storage that "sys" points to. tools/perf/util/trace-event-read.c:353: leaked_storage: Variable "sys" going out of scope leaks the storage it points to. Signed-off-by: Sanskriti Sharma Reviewed-by: Jiri Olsa Cc: Joe Lawrence Link: http://lkml.kernel.org/r/1538490554-8161-6-git-send-email-sansharm@redhat.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- tools/perf/util/trace-event-read.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/tools/perf/util/trace-event-read.c +++ b/tools/perf/util/trace-event-read.c @@ -349,9 +349,12 @@ static int read_event_files(struct tep_h for (x=0; x < count; x++) { size = read8(pevent); ret = read_event_file(pevent, sys, size); - if (ret) + if (ret) { + free(sys); return ret; + } } + free(sys); } return 0; }