mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: tip-bot for Sanskriti Sharma <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: mingo@kernel.org, sansharm@redhat.com, jolsa@kernel.org,
	joe.lawrence@redhat.com, linux-kernel@vger.kernel.org,
	hpa@zytor.com, tglx@linutronix.de, acme@redhat.com
Subject: [tip:perf/core] perf tools: Avoid double free in read_event_file()
Date: Mon, 8 Oct 2018 22:31:01 -0700	[thread overview]
Message-ID: <tip-470c8f7c88de013d266e1b61044efe8937728b7f@git.kernel.org> (raw)
In-Reply-To: <1538490554-8161-5-git-send-email-sansharm@redhat.com>

Commit-ID:  470c8f7c88de013d266e1b61044efe8937728b7f
Gitweb:     https://git.kernel.org/tip/470c8f7c88de013d266e1b61044efe8937728b7f
Author:     Sanskriti Sharma <sansharm@redhat.com>
AuthorDate: Tue, 2 Oct 2018 10:29:13 -0400
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 8 Oct 2018 14:23:46 -0300

perf tools: Avoid double free in read_event_file()

The temporary 'buf' buffer allocated in read_event_file() may be freed
twice.  Move the free() call to the common function exit point.

Fixes the following coverity complaints:

  Error: USE_AFTER_FREE (CWE-825):
  tools/perf/util/trace-event-read.c:309: double_free: Calling "free"
  frees pointer "buf" which has already been freed.

Signed-off-by: Sanskriti Sharma <sansharm@redhat.com>
Reviewed-by: Jiri Olsa <jolsa@kernel.org>
Cc: Joe Lawrence <joe.lawrence@redhat.com>
Link: http://lkml.kernel.org/r/1538490554-8161-5-git-send-email-sansharm@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/trace-event-read.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/tools/perf/util/trace-event-read.c b/tools/perf/util/trace-event-read.c
index b98ee2a2eb44..a278e1eee5f5 100644
--- a/tools/perf/util/trace-event-read.c
+++ b/tools/perf/util/trace-event-read.c
@@ -297,10 +297,8 @@ static int read_event_file(struct tep_handle *pevent, char *sys,
 	}
 
 	ret = do_read(buf, size);
-	if (ret < 0) {
-		free(buf);
+	if (ret < 0)
 		goto out;
-	}
 
 	ret = parse_event_file(pevent, buf, size, sys);
 	if (ret < 0)

  parent reply	other threads:[~2018-10-09  5:31 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-02 14:29 [PATCH 0/5] perf tool: small coverity clean ups Sanskriti Sharma
2018-10-02 14:29 ` [PATCH 1/5] perf strbuf: match va_{add,copy} with va_end Sanskriti Sharma
2018-10-02 15:45   ` Arnaldo Carvalho de Melo
2018-10-09  5:29   ` [tip:perf/core] perf strbuf: Match " tip-bot for Sanskriti Sharma
2018-10-02 14:29 ` [PATCH 2/5] perf tools: cleanup trace-event-info 'tdata' leak Sanskriti Sharma
2018-10-02 15:47   ` Arnaldo Carvalho de Melo
2018-10-09  5:29   ` [tip:perf/core] perf tools: Cleanup " tip-bot for Sanskriti Sharma
2018-10-02 14:29 ` [PATCH 3/5] perf tools: free 'printk' string in parse_ftrace_printk() Sanskriti Sharma
2018-10-02 15:47   ` Arnaldo Carvalho de Melo
2018-10-09  5:30   ` [tip:perf/core] perf tools: Free " tip-bot for Sanskriti Sharma
2018-10-02 14:29 ` [PATCH 4/5] perf tools: avoid double free in read_event_file() Sanskriti Sharma
2018-10-02 15:48   ` Arnaldo Carvalho de Melo
2018-10-09  5:31   ` tip-bot for Sanskriti Sharma [this message]
2018-10-02 14:29 ` [PATCH 5/5] perf tools: free temporary 'sys' string in read_event_files() Sanskriti Sharma
2018-10-02 15:50   ` Arnaldo Carvalho de Melo
2018-10-09  5:31   ` [tip:perf/core] perf tools: Free " tip-bot for Sanskriti Sharma
2018-10-02 16:02 ` [PATCH 0/5] perf tool: small coverity clean ups Jiri Olsa
2018-10-02 16:14   ` Arnaldo Carvalho de Melo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tip-470c8f7c88de013d266e1b61044efe8937728b7f@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=acme@redhat.com \
    --cc=hpa@zytor.com \
    --cc=joe.lawrence@redhat.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=sansharm@redhat.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome