Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3440188imu; Sun, 11 Nov 2018 15:08:43 -0800 (PST) X-Google-Smtp-Source: AJdET5ce0DSVmjuXCtjfJ5q0rhGlv3CDXgIo/Rk9ZHtOC78XRcvegDYEwl6GeLJoNf7/hT+4sJqV X-Received: by 2002:a62:8d51:: with SMTP id z78-v6mr14029826pfd.234.1541977723285; Sun, 11 Nov 2018 15:08:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541977723; cv=none; d=google.com; s=arc-20160816; b=KFglz8GSXYPKnun1V3sijVskHT7PTkQgX/TGb8d5VqHx7OeaGE6d1A7iFtyiUajQwm 6s8YrKB+O+VmSRtxD8Pmf3AZ42SjmVi/w155MRLzKS9dNdgtOe5yTYv5d0JBmyIoQNwi 2VVjF/9VfwHdcgW6NxqSnJYTwg+WniNPa/Em4h7Zx2ZGumnCQtP4jzSHq8SdP5xrQ+nR e8949MgoLsxegzrqygvGFjvcEH1RMcC7X4OpCfsaN5swaOkGHDHzukiizD6QLF2GQcvR akey6v4VvD+XxZuyZivsG5r80M8sGGZDEYHa+bFzb/9F0LBWshiRGhPSK1vbSia0nVkL n+Kw== 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=HKiQFoj5lsVd49Z1Lk/f9pwfieMp7gh1BrWxuo+7xmM=; b=HpEm+u4E4J6rPTSxjnFU1rV4kqUQlBMiHfozGJRMbiyPm2hKK5IDTaptdguz6ita17 ruW2otm1SjXjWn1Tz+0n4PUve0Mt6yriwweam3IUOuDZhft8iNeiuD9i6GzqJ0o/LXoI 1GQqqSpemv8KYSobq8t7Ci2IqpORHjF3CiOhJ6rdGhLYu8bbayNTXXVEqnDGl5Sa6x5y Hs1P2qdbx8d2eXORqvmvysiz9lEO0YN68w92LtT9jf0iLt9KVEheYyeweVTxsjE+sKAx FENHBsGGXS484D6WMT/w7nmHoZqvfOlEWEpu/z8pUkJRpsqPCRjxisn7Oul/WCu11vwQ f7Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Uhh74hDV; 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 j20si14903963pgh.224.2018.11.11.15.08.28; Sun, 11 Nov 2018 15:08:43 -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=Uhh74hDV; 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 S2390535AbeKLI4x (ORCPT + 99 others); Mon, 12 Nov 2018 03:56:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:51248 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390325AbeKLIWL (ORCPT ); Mon, 12 Nov 2018 03:22:11 -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 7099E2243E; Sun, 11 Nov 2018 22:32:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975534; bh=R+IyGCFzj7hf+02l2LR5nw4DkAm4ruD42J91Uw88rNs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Uhh74hDV0RBbtGKWKok3t4So0POWT9fDMJRLRtw95nK5NebYaB17dHfoSfKDT9NQK LtoTegXvDcuhsWDtG9NV3HCFDSj8V37FQOPww2L96J7+jL8ZL7xxyT4TD0Sq12IToi SX/eOCkJJpnhR6ZlPtUMZeEGVnWedxUC2zIpsRUI= 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.14 048/222] perf tools: Free temporary sys string in read_event_files() Date: Sun, 11 Nov 2018 14:22:25 -0800 Message-Id: <20181111221652.408366596@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221647.665769131@linuxfoundation.org> References: <20181111221647.665769131@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.14-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 @@ -350,9 +350,12 @@ static int read_event_files(struct peven 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; }