Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a6ced2be authored by Adrian Hunter's avatar Adrian Hunter Committed by Arnaldo Carvalho de Melo
Browse files

perf tools: Fix parse_events_error dereferences



Parse errors can be reported in struct parse_events_error but the
pointer passed is optional and can be NULL.  Ensure it is not NULL
before dereferencing it.

Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@gmail.com>
Link: http://lkml.kernel.org/r/1432040746-1755-4-git-send-email-adrian.hunter@intel.com


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent bb78ce7d
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1659,6 +1659,8 @@ void parse_events_evlist_error(struct parse_events_evlist *data,
{
	struct parse_events_error *err = data->error;

	if (!err)
		return;
	err->idx = idx;
	err->str = strdup(str);
	WARN_ONCE(!err->str, "WARNING: failed to allocate error string");
+4 −2
Original line number Diff line number Diff line
@@ -389,8 +389,10 @@ PE_NAME ':' PE_NAME
	if (parse_events_add_tracepoint(list, &data->idx, $1, $3)) {
		struct parse_events_error *error = data->error;

		if (error) {
			error->idx = @1.first_column;
			error->str = strdup("unknown tracepoint");
		}
		return -1;
	}
	$$ = list;