Commit 062d6c2a authored by Masami Hiramatsu's avatar Masami Hiramatsu Committed by Arnaldo Carvalho de Melo

perf probe: Close target file on error path

Fix a bug to close target elf file in get_text_start_address().
Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20160426064737.1443.44093.stgit@devboxSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent b04b7023
...@@ -486,8 +486,10 @@ static int get_text_start_address(const char *exec, unsigned long *address) ...@@ -486,8 +486,10 @@ static int get_text_start_address(const char *exec, unsigned long *address)
return -errno; return -errno;
elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL); elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL);
if (elf == NULL) if (elf == NULL) {
return -EINVAL; ret = -EINVAL;
goto out_close;
}
if (gelf_getehdr(elf, &ehdr) == NULL) if (gelf_getehdr(elf, &ehdr) == NULL)
goto out; goto out;
...@@ -499,6 +501,9 @@ static int get_text_start_address(const char *exec, unsigned long *address) ...@@ -499,6 +501,9 @@ static int get_text_start_address(const char *exec, unsigned long *address)
ret = 0; ret = 0;
out: out:
elf_end(elf); elf_end(elf);
out_close:
close(fd);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment