lkml.org 
[lkml]   [2013]   [Oct]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2] tools/perf/util: Fix memory leak in trace-event-info.c
Date
Fix for a memory leak on tracing_data_get() function when returning NULL explicitly

Signed-off-by: Felipe Pena <felipensp@gmail.com>
---
tools/perf/util/trace-event-info.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/trace-event-info.c b/tools/perf/util/trace-event-info.c
index f3c9e55..2a0c3c9 100644
--- a/tools/perf/util/trace-event-info.c
+++ b/tools/perf/util/trace-event-info.c
@@ -518,13 +518,15 @@ 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");
- return NULL;
+ err = -1;
+ goto err_tdata;
}

temp_fd = open(tdata->temp_file, O_RDWR);
if (temp_fd < 0) {
pr_debug("Can't read '%s'", tdata->temp_file);
- return NULL;
+ err = -1;
+ goto err_tdata;
}

/*
@@ -562,6 +564,7 @@ out:
output_fd = fd;
}

+err_tdata:
if (err) {
free(tdata);
tdata = NULL;
--
1.7.10.4


\
 
 \ /
  Last update: 2013-10-11 03:41    [W:0.032 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site