Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp179167imd; Wed, 31 Oct 2018 16:55:17 -0700 (PDT) X-Google-Smtp-Source: AJdET5dv3T4f3x/ACXzClEcQe//6DpZSZgRgTecEc4IgKvMT5O/I+mmSneZzNJxJ3HlDFJkzYJEi X-Received: by 2002:a65:5286:: with SMTP id y6mr2922609pgp.439.1541030117692; Wed, 31 Oct 2018 16:55:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541030117; cv=none; d=google.com; s=arc-20160816; b=M0fYOW6bMRn/8QE+NxSOyhEyritUF0+/E2aPWLWD2H7nDMllIB/V8PIpPvctRjRFgQ 4rYQx9ZdPgW8AgJE+1C2fZ/fkfLayFA+CnL9ZkF+ke/OV25LofRjMMmeDystIE3w9L8R VFMB0yzL7geEbc+iuy4V55XQKcd8TU0lul9GH1MQrDmHSzw4eyUINLPkhByC/2nTHSuk i1EbcadZxxXvpIspI6acqAAlwZ8ddmRN2I61COESSlrpSoI/TcYvAovff7+/QU99qbJh FbCu3brtaUoajox5q6lGNDQEeSTUtSOXiLdrjHzufkVep6OTbsbqdVsDJPDvvLKb6GQP ZGxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=dPbrwdVbssznxwiklVzJGLYOy9CdDnJ7+Af/ieEYGEo=; b=uhQCdjVERsfTernqHGgTR3oQ/3HweGHniQL2I/XQDu9sIoe2JD4kzN45vfZMOX01Fh cGoFT0xXFcBVG62ZYDK2hoZHG1uBZTm6zTlGb3eO+CRJ9G0iLJXLsirOGhv4lmm+DEMZ bp9xE5ulnHIMr0BsPc4bkNbllQ4mt5cqfQbDAwarkEFa+nw17ekTxSSa7XnO8CK/S6yS R9AMf37BTju9Mt5taZFBTWWnQW16K0lZv4tbSRPcKQTz4qgrcq2dLGcBcO3Q+XXwuTID 3TOIaj5HD9Rjf3ZPEiaBRqGs2GVuTyOkgPGD0EEVBxW8bMgsXvIwiWzWk8rudfE5ew0/ HPwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=g6QN5EUq; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f12-v6si27377403pgo.136.2018.10.31.16.55.02; Wed, 31 Oct 2018 16:55:17 -0700 (PDT) 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=g6QN5EUq; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727653AbeKAIGL (ORCPT + 99 others); Thu, 1 Nov 2018 04:06:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:52950 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727630AbeKAIGK (ORCPT ); Thu, 1 Nov 2018 04:06:10 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A441320823; Wed, 31 Oct 2018 23:05:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541027160; bh=/UnV7f4efCNnuHnFaiGBHQQzWtx0AD4VBrhAJZCcOl4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g6QN5EUqYsUpQ0CzKasM8OMzjsFDOaiUmYoF10tXMphJMXpI8a5G5Pw6vsfwzu4EY +tcIqO3LFkzUFxyaZhtaqL9hgbRlKs0DLlQer1t/4YaWKfKYRNA7bkq0zt+RxcIp0Q TWMZGf11P9YcZ+y6RBVaB4v/MSURkFC7LfVnc7Ws= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sanskriti Sharma , Joe Lawrence , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH AUTOSEL 4.19 019/146] perf tools: Cleanup trace-event-info 'tdata' leak Date: Wed, 31 Oct 2018 19:03:34 -0400 Message-Id: <20181031230541.28822-19-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031230541.28822-1-sashal@kernel.org> References: <20181031230541.28822-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sanskriti Sharma [ Upstream commit faedbf3fd19f2511a39397f76359e4cc6ee93072 ] 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 Signed-off-by: Sasha Levin --- 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; } -- 2.17.1