4.14-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Sanskriti Sharma <[email protected]>

[ 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 <[email protected]>
Reviewed-by: Jiri Olsa <[email protected]>
Cc: Joe Lawrence <[email protected]>
Link: 
http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
 tools/perf/util/trace-event-info.c |    2 ++
 1 file changed, 2 insertions(+)

--- a/tools/perf/util/trace-event-info.c
+++ b/tools/perf/util/trace-event-info.c
@@ -533,12 +533,14 @@ struct tracing_data *tracing_data_get(st
                         "/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;
                }
 


Reply via email to