[PATCH 1/7] perf inject: don't proceed if perf_session__process_event fails

David Carrillo-Cisneros
2017-04-10T20:15:05Z

All paths following perf_session__process_event in __cmd_inject are
useless if __cmd_inject is to fail, some depend on a correct
session->evlist.

First commit to add code that depends on session->evlist without checking
error was commmit e558a5bd8b ("perf inject: Work with files"). It has
grown since then.

Change __cmd_inject to fail immediately after perf_session__process_event
fails.

Signed-off-by: David Carrillo-Cisneros <davidcc@google.com>
---
tools/perf/builtin-inject.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
index 42dff0b1375a..65e1c026a2f0 100644
--- a/tools/perf/builtin-inject.c
+++ b/tools/perf/builtin-inject.c
@@ -694,6 +694,8 @@ static int __cmd_inject(struct perf_inject *inject)
lseek(fd, output_data_offset, SEEK_SET);

ret = perf_session__process_events(session);
+ if (ret)
+ return ret;

if (!file_out->is_pipe) {
if (inject->build_ids)
--
2.12.2.715.g7642488e1d-goog