perf tools: Fix a memory leak in __open_dso()
authorNamhyung Kim <[email protected]>
Thu, 8 Jun 2017 07:31:02 +0000 (16:31 +0900)
committerArnaldo Carvalho de Melo <[email protected]>
Thu, 8 Jun 2017 18:38:47 +0000 (15:38 -0300)
The 'name' variable should be freed on the error path.

Signed-off-by: Namhyung Kim <[email protected]>
Acked-by: Jiri Olsa <[email protected]>
Cc: Adrian Hunter <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Wang Nan <[email protected]>
Cc: [email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
tools/perf/util/dso.c

index b27d127cdf68f996ee4f96ce24aa51044e31bf9f..1f29e4fe7af08e6faa766ea63ed08540e955620a 100644 (file)
@@ -412,8 +412,10 @@ static int __open_dso(struct dso *dso, struct machine *machine)
                return -EINVAL;
        }
 
-       if (!is_regular_file(name))
+       if (!is_regular_file(name)) {
+               free(name);
                return -EINVAL;
+       }
 
        fd = do_open(name);
        free(name);