All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [BUGFIX]perf probe: Fix to close target file
@ 2016-04-26  6:35 Masami Hiramatsu
  2016-04-26  6:47 ` [PATCH v2] " Masami Hiramatsu
  0 siblings, 1 reply; 4+ messages in thread
From: Masami Hiramatsu @ 2016-04-26  6:35 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Masami Hiramatsu, linux-kernel, Namhyung Kim, Peter Zijlstra,
	Ingo Molnar

Fix a bug to close target elf file in get_text_start_address().

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
 tools/perf/util/probe-event.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 8319fbb..258b49d 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -499,6 +499,7 @@ static int get_text_start_address(const char *exec, unsigned long *address)
 	ret = 0;
 out:
 	elf_end(elf);
+	close(fd);
 	return ret;
 }
 

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2] [BUGFIX]perf probe: Fix to close target file
  2016-04-26  6:35 [PATCH] [BUGFIX]perf probe: Fix to close target file Masami Hiramatsu
@ 2016-04-26  6:47 ` Masami Hiramatsu
  2016-04-26 13:31   ` Arnaldo Carvalho de Melo
  2016-04-27 15:34   ` [tip:perf/core] perf probe: Close target file on error path tip-bot for Masami Hiramatsu
  0 siblings, 2 replies; 4+ messages in thread
From: Masami Hiramatsu @ 2016-04-26  6:47 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Masami Hiramatsu, linux-kernel, Namhyung Kim, Peter Zijlstra,
	Ingo Molnar

Fix a bug to close target elf file in get_text_start_address().

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
  Changes in v2:
   - handle an error case in elf_begin() too.
---
 tools/perf/util/probe-event.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 8319fbb..97b7f8e 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -486,8 +486,10 @@ static int get_text_start_address(const char *exec, unsigned long *address)
 		return -errno;
 
 	elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL);
-	if (elf == NULL)
-		return -EINVAL;
+	if (elf == NULL) {
+		ret = -EINVAL;
+		goto out_close;
+	}
 
 	if (gelf_getehdr(elf, &ehdr) == NULL)
 		goto out;
@@ -499,6 +501,9 @@ static int get_text_start_address(const char *exec, unsigned long *address)
 	ret = 0;
 out:
 	elf_end(elf);
+out_close:
+	close(fd);
+
 	return ret;
 }
 

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] [BUGFIX]perf probe: Fix to close target file
  2016-04-26  6:47 ` [PATCH v2] " Masami Hiramatsu
@ 2016-04-26 13:31   ` Arnaldo Carvalho de Melo
  2016-04-27 15:34   ` [tip:perf/core] perf probe: Close target file on error path tip-bot for Masami Hiramatsu
  1 sibling, 0 replies; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-04-26 13:31 UTC (permalink / raw)
  To: Masami Hiramatsu; +Cc: linux-kernel, Namhyung Kim, Peter Zijlstra, Ingo Molnar

Em Tue, Apr 26, 2016 at 03:47:37PM +0900, Masami Hiramatsu escreveu:
> Fix a bug to close target elf file in get_text_start_address().
> 
> Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>

Thanks, applied.

- Arnaldo

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [tip:perf/core] perf probe: Close target file on error path
  2016-04-26  6:47 ` [PATCH v2] " Masami Hiramatsu
  2016-04-26 13:31   ` Arnaldo Carvalho de Melo
@ 2016-04-27 15:34   ` tip-bot for Masami Hiramatsu
  1 sibling, 0 replies; 4+ messages in thread
From: tip-bot for Masami Hiramatsu @ 2016-04-27 15:34 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: tglx, mingo, hpa, peterz, namhyung, linux-kernel, acme, mhiramat

Commit-ID:  062d6c2aec0e087be956494a73221c04eca115fe
Gitweb:     http://git.kernel.org/tip/062d6c2aec0e087be956494a73221c04eca115fe
Author:     Masami Hiramatsu <mhiramat@kernel.org>
AuthorDate: Tue, 26 Apr 2016 15:47:37 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 26 Apr 2016 10:56:08 -0300

perf probe: Close target file on error path

Fix a bug to close target elf file in get_text_start_address().

Signed-off-by: Masami 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@devbox
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/probe-event.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 8319fbb..97b7f8e 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -486,8 +486,10 @@ static int get_text_start_address(const char *exec, unsigned long *address)
 		return -errno;
 
 	elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL);
-	if (elf == NULL)
-		return -EINVAL;
+	if (elf == NULL) {
+		ret = -EINVAL;
+		goto out_close;
+	}
 
 	if (gelf_getehdr(elf, &ehdr) == NULL)
 		goto out;
@@ -499,6 +501,9 @@ static int get_text_start_address(const char *exec, unsigned long *address)
 	ret = 0;
 out:
 	elf_end(elf);
+out_close:
+	close(fd);
+
 	return ret;
 }
 

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-04-27 15:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-26  6:35 [PATCH] [BUGFIX]perf probe: Fix to close target file Masami Hiramatsu
2016-04-26  6:47 ` [PATCH v2] " Masami Hiramatsu
2016-04-26 13:31   ` Arnaldo Carvalho de Melo
2016-04-27 15:34   ` [tip:perf/core] perf probe: Close target file on error path tip-bot for Masami Hiramatsu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.