From: Alexander Shishkin Date: Tue, 5 Nov 2019 07:57:02 +0000 (+0200) Subject: perf/core: Consistently fail fork on allocation failures X-Git-Tag: v5.3.16~85 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b9366c7cb7d0e5b302d337921c87ddc870bb6c3a;p=thirdparty%2Fkernel%2Fstable.git perf/core: Consistently fail fork on allocation failures [ Upstream commit 697d877849d4b34ab58d7078d6930bad0ef6fc66 ] 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 Signed-off-by: Peter Zijlstra (Intel) Cc: Arnaldo Carvalho de Melo Cc: David Ahern Cc: Jiri Olsa Cc: Jiri Olsa Cc: Linus Torvalds Cc: Mark Rutland Cc: Namhyung Kim Cc: Stephane Eranian Cc: Thomas Gleixner Cc: Vince Weaver Link: https://lkml.kernel.org/r/20191105075702.60319-1-alexander.shishkin@linux.intel.com Signed-off-by: Ingo Molnar Signed-off-by: Sasha Levin --- diff --git a/kernel/events/core.c b/kernel/events/core.c index 53173883513c1..25942e43b8d48 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -11719,7 +11719,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); } }