linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	David Ahern <dsahern@gmail.com>, Jiri Olsa <jolsa@kernel.org>,
	Jiri Olsa <jolsa@redhat.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Namhyung Kim <namhyung@kernel.org>,
	Stephane Eranian <eranian@google.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Vince Weaver <vincent.weaver@maine.edu>,
	Ingo Molnar <mingo@kernel.org>, Sasha Levin <sashal@kernel.org>
Subject: [PATCH AUTOSEL 4.19 11/25] perf/core: Consistently fail fork on allocation failures
Date: Fri, 22 Nov 2019 14:48:44 -0500	[thread overview]
Message-ID: <20191122194859.24508-11-sashal@kernel.org> (raw)
In-Reply-To: <20191122194859.24508-1-sashal@kernel.org>

From: Alexander Shishkin <alexander.shishkin@linux.intel.com>

[ 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 <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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/events/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 625ba462e5bbd..460d5fd3ec4e4 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -11377,7 +11377,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);
 		}
 	}
 
-- 
2.20.1


  parent reply	other threads:[~2019-11-22 19:54 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-22 19:48 [PATCH AUTOSEL 4.19 01/25] autofs: fix a leak in autofs_expire_indirect() Sasha Levin
2019-11-22 19:48 ` [PATCH AUTOSEL 4.19 02/25] RDMA/hns: Correct the value of HNS_ROCE_HEM_CHUNK_LEN Sasha Levin
2019-11-22 19:48 ` [PATCH AUTOSEL 4.19 03/25] xfrm: Fix memleak on xfrm state destroy Sasha Levin
2019-11-22 19:48 ` [PATCH AUTOSEL 4.19 04/25] iwlwifi: pcie: don't consider IV len in A-MSDU Sasha Levin
2019-11-22 19:48 ` [PATCH AUTOSEL 4.19 05/25] exportfs_decode_fh(): negative pinned may become positive without the parent locked Sasha Levin
2019-11-22 19:48 ` [PATCH AUTOSEL 4.19 06/25] audit_get_nd(): don't unlock parent too early Sasha Levin
2019-11-22 19:48 ` [PATCH AUTOSEL 4.19 07/25] NFC: nxp-nci: Fix NULL pointer dereference after I2C communication error Sasha Levin
2019-11-22 19:48 ` [PATCH AUTOSEL 4.19 08/25] xfrm: release device reference for invalid state Sasha Levin
2019-11-22 19:48 ` [PATCH AUTOSEL 4.19 09/25] Input: cyttsp4_core - fix use after free bug Sasha Levin
2019-11-22 19:48 ` [PATCH AUTOSEL 4.19 10/25] sched/core: Avoid spurious lock dependencies Sasha Levin
2019-11-22 19:48 ` Sasha Levin [this message]
2019-11-22 19:48 ` [PATCH AUTOSEL 4.19 12/25] ALSA: pcm: Fix stream lock usage in snd_pcm_period_elapsed() Sasha Levin
2019-11-22 19:48 ` [PATCH AUTOSEL 4.19 13/25] drm/sun4i: tcon: Set min division of TCON0_DCLK to 1 Sasha Levin
2019-11-22 19:48 ` [PATCH AUTOSEL 4.19 14/25] selftests: kvm: fix build with glibc >= 2.30 Sasha Levin
2019-11-22 19:48 ` [PATCH AUTOSEL 4.19 15/25] net: usb: qmi_wwan: add support for Foxconn T77W968 LTE modules Sasha Levin
2019-11-22 19:48 ` [PATCH AUTOSEL 4.19 16/25] slip: Fix memory leak in slip_open error path Sasha Levin
2019-11-22 19:48 ` [PATCH AUTOSEL 4.19 17/25] net: cdc_ncm: Signedness bug in cdc_ncm_set_dgram_size() Sasha Levin
2019-11-22 19:48 ` [PATCH AUTOSEL 4.19 18/25] slcan: Fix memory leak in error path Sasha Levin
2019-11-22 19:48 ` [PATCH AUTOSEL 4.19 19/25] rsxx: add missed destroy_workqueue calls in remove Sasha Levin
2019-11-22 19:48 ` [PATCH AUTOSEL 4.19 20/25] ax88172a: fix information leak on short answers Sasha Levin
2019-11-22 19:48 ` [PATCH AUTOSEL 4.19 21/25] net: ep93xx_eth: fix mismatch of request_mem_region in remove Sasha Levin
2019-11-22 19:48 ` [PATCH AUTOSEL 4.19 22/25] i2c: acpi: Force bus speed to 400KHz if a Silead touchscreen is present Sasha Levin
2019-11-22 19:48 ` [PATCH AUTOSEL 4.19 23/25] i2c: core: fix use after free in of_i2c_notify Sasha Levin
2019-11-22 19:48 ` [PATCH AUTOSEL 4.19 24/25] Input: synaptics - enable RMI mode for X1 Extreme 2nd Generation Sasha Levin
2019-11-22 19:55   ` Dmitry Torokhov
2019-12-06 12:14     ` Sasha Levin
2019-11-22 19:48 ` [PATCH AUTOSEL 4.19 25/25] net: gemini: add missed free_netdev Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191122194859.24508-11-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=acme@redhat.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=dsahern@gmail.com \
    --cc=eranian@google.com \
    --cc=jolsa@kernel.org \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=vincent.weaver@maine.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).