perf/core: Consistently fail fork on allocation failures
authorAlexander Shishkin <alexander.shishkin@linux.intel.com>
Tue, 5 Nov 2019 07:57:02 +0000 (09:57 +0200)
committerIngo Molnar <mingo@kernel.org>
Wed, 13 Nov 2019 07:16:43 +0000 (08:16 +0100)
Commit:

  313ccb9615948 ("perf: Allocate context task_ctx_data for child event")

makes the inherit path skip over the current event in case of task_ctx_data
allocation failure. This, however, is inconsistent with allocation failures
in perf_event_alloc(), which would abort the fork.

Correct this by returning an error code on task_ctx_data allocation
failure and failing the fork in that case.

Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Link: https://lkml.kernel.org/r/20191105075702.60319-1-alexander.shishkin@linux.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
kernel/events/core.c

index 7655441065a96ed439759776fa356495a6bdc76a..466e333db1f3648d470397a0d14b843616f23a44 100644 (file)
@@ -11802,7 +11802,7 @@ inherit_event(struct perf_event *parent_event,
                                                   GFP_KERNEL);
                if (!child_ctx->task_ctx_data) {
                        free_event(child_event);
-                       return NULL;
+                       return ERR_PTR(-ENOMEM);
                }
        }