From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7563C432C0 for ; Fri, 22 Nov 2019 19:54:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A4F0B20704 for ; Fri, 22 Nov 2019 19:54:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574452474; bh=zwqM+wS2Wryn1l8lu7xVA8FqBKoSghxz/FEIeQeJyFE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=MJhJWr8ssik1CuMO9BncL4dZGHOgZjkbQf+8mYuxA4y/QY4Utwtfxe5qqIN9yP2aK k3drEchmsykv0GJisuopVDEyn5RYvmu0IkQU+sZWuVMJXNWrankJdBvbjx9elReaqZ TVzE7iBTrzSM2Rfgu7bW7Rtcb4L2usd3+oy+0Reg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727255AbfKVTyd (ORCPT ); Fri, 22 Nov 2019 14:54:33 -0500 Received: from mail.kernel.org ([198.145.29.99]:48412 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727176AbfKVTtO (ORCPT ); Fri, 22 Nov 2019 14:49:14 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 34C3C20726; Fri, 22 Nov 2019 19:49:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574452153; bh=zwqM+wS2Wryn1l8lu7xVA8FqBKoSghxz/FEIeQeJyFE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u95+oyOWgbSqfe7EAksSSYfkWY1q82kesVP/oDye4SDkOvpjSPD9FWHI3mMILeovo zPrCthWJYr9yBQgIvbDFZY8VwAcorpHrr74h3OMEUUkcNG4a7GiaGYj6WjvRaaRqp2 JvpqiTj6UsO1PnWRpV5v4NdZBvviMWVuZRBYr91s= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Alexander Shishkin , Peter Zijlstra , Arnaldo Carvalho de Melo , David Ahern , Jiri Olsa , Jiri Olsa , Linus Torvalds , Mark Rutland , Namhyung Kim , Stephane Eranian , Thomas Gleixner , Vince Weaver , Ingo Molnar , Sasha Levin Subject: [PATCH AUTOSEL 4.19 11/25] perf/core: Consistently fail fork on allocation failures Date: Fri, 22 Nov 2019 14:48:44 -0500 Message-Id: <20191122194859.24508-11-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191122194859.24508-1-sashal@kernel.org> References: <20191122194859.24508-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexander Shishkin [ 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 --- 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