From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC4A4C64EB0 for ; Tue, 9 Oct 2018 05:30:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A8C3220C0A for ; Tue, 9 Oct 2018 05:30:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A8C3220C0A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=zytor.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726647AbeJIMpL (ORCPT ); Tue, 9 Oct 2018 08:45:11 -0400 Received: from terminus.zytor.com ([198.137.202.136]:43049 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725823AbeJIMpL (ORCPT ); Tue, 9 Oct 2018 08:45:11 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w995Tv3n909927 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 8 Oct 2018 22:29:57 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w995TvI8909924; Mon, 8 Oct 2018 22:29:57 -0700 Date: Mon, 8 Oct 2018 22:29:57 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Sanskriti Sharma Message-ID: Cc: mingo@kernel.org, tglx@linutronix.de, hpa@zytor.com, acme@redhat.com, joe.lawrence@redhat.com, sansharm@redhat.com, linux-kernel@vger.kernel.org, jolsa@kernel.org Reply-To: acme@redhat.com, hpa@zytor.com, tglx@linutronix.de, mingo@kernel.org, sansharm@redhat.com, linux-kernel@vger.kernel.org, jolsa@kernel.org, joe.lawrence@redhat.com In-Reply-To: <1538490554-8161-3-git-send-email-sansharm@redhat.com> References: <1538490554-8161-3-git-send-email-sansharm@redhat.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf tools: Cleanup trace-event-info 'tdata' leak Git-Commit-ID: faedbf3fd19f2511a39397f76359e4cc6ee93072 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: faedbf3fd19f2511a39397f76359e4cc6ee93072 Gitweb: https://git.kernel.org/tip/faedbf3fd19f2511a39397f76359e4cc6ee93072 Author: Sanskriti Sharma AuthorDate: Tue, 2 Oct 2018 10:29:11 -0400 Committer: Arnaldo Carvalho de Melo CommitDate: Mon, 8 Oct 2018 14:23:45 -0300 perf tools: Cleanup trace-event-info 'tdata' leak Free tracing_data structure in tracing_data_get() error paths. Fixes the following coverity complaint: Error: RESOURCE_LEAK (CWE-772): leaked_storage: Variable "tdata" going out of scope leaks the storage Signed-off-by: Sanskriti Sharma Reviewed-by: Jiri Olsa Cc: Joe Lawrence Link: http://lkml.kernel.org/r/1538490554-8161-3-git-send-email-sansharm@redhat.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/trace-event-info.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/perf/util/trace-event-info.c b/tools/perf/util/trace-event-info.c index 7b0ca7cbb7de..8ad8e755127b 100644 --- a/tools/perf/util/trace-event-info.c +++ b/tools/perf/util/trace-event-info.c @@ -531,12 +531,14 @@ struct tracing_data *tracing_data_get(struct list_head *pattrs, "/tmp/perf-XXXXXX"); if (!mkstemp(tdata->temp_file)) { pr_debug("Can't make temp file"); + free(tdata); return NULL; } temp_fd = open(tdata->temp_file, O_RDWR); if (temp_fd < 0) { pr_debug("Can't read '%s'", tdata->temp_file); + free(tdata); return NULL; }