提交 b2ad2430 编写于 作者: S Sanskriti Sharma 提交者: Greg Kroah-Hartman

perf tools: Cleanup trace-event-info 'tdata' leak

[ 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: NSanskriti Sharma <sansharm@redhat.com>
Reviewed-by: NJiri Olsa <jolsa@kernel.org>
Cc: Joe Lawrence <joe.lawrence@redhat.com>
Link: http://lkml.kernel.org/r/1538490554-8161-3-git-send-email-sansharm@redhat.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 8e4b8246
...@@ -531,12 +531,14 @@ struct tracing_data *tracing_data_get(struct list_head *pattrs, ...@@ -531,12 +531,14 @@ struct tracing_data *tracing_data_get(struct list_head *pattrs,
"/tmp/perf-XXXXXX"); "/tmp/perf-XXXXXX");
if (!mkstemp(tdata->temp_file)) { if (!mkstemp(tdata->temp_file)) {
pr_debug("Can't make temp file"); pr_debug("Can't make temp file");
free(tdata);
return NULL; return NULL;
} }
temp_fd = open(tdata->temp_file, O_RDWR); temp_fd = open(tdata->temp_file, O_RDWR);
if (temp_fd < 0) { if (temp_fd < 0) {
pr_debug("Can't read '%s'", tdata->temp_file); pr_debug("Can't read '%s'", tdata->temp_file);
free(tdata);
return NULL; return NULL;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册