Received: by 10.192.165.156 with SMTP id m28csp1136513imm; Wed, 11 Apr 2018 13:07:09 -0700 (PDT) X-Google-Smtp-Source: AIpwx48TGBVfDkN1WVX7XxkuKy73MSamKkVv3o4p1YvjsDzvIEt/ocApb691JFLTziCmkqxxiuYy X-Received: by 2002:a17:902:8f94:: with SMTP id z20-v6mr6587774plo.174.1523477228953; Wed, 11 Apr 2018 13:07:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523477228; cv=none; d=google.com; s=arc-20160816; b=NTLQQzdTIx3SYOuz3mEdnsnaJRPcfb+r8hL4UZK8wthMr4m57vIrA+58pIpUGbFauy alyyptba0XcCLe4hNQcJfjkdv3YHbiGXlANC+1TM/AafCul+3o76pG0QnzddL+Ix2DUh H46thRymtLMnLvNoX+AkzxxgiSVSTv+zXxUBcVZJ82OuYyVUWZvRqPLmXUt71gf0MCAi rTTNxg3jsoNALJorBymDjEcSnx3EVaGXZfu84JjEXc1UeN385pXiVAbcpgqtbSUKr8hq VBvzIz8uhLneK48cNa4yfABeH08kmO/553hwITQrTSkbaxIjP28PuSbIIW2Ad6okprgE qWzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=6aZZWtnZY4iXqDTl5imZE0yEJjew+t0jpOCf7zIVEVc=; b=XMX7qkPRsBeCpCe8NzdbfO0fb+37P6EuWSBuBlSZ/SdcgdEpTvdGmdQ9fosdcJLO+a ZKp4lHU1TYyDOggxWg0q9vQbo29Vl/RI8Xg9LD/748+dH8Dvcv0E4WLfOSLePJVpBE0e nk/O3OrUWhchJl58mwKgqSKqoMJJ3vFWfx9atx45Ta2SCNHQaGTkg3Wg7AWuocd3D4dX wUfItuvjWihOEcEsgC0UdnXhCno2Im0mF+jTkd/fz80/9xXpSUGHe9WJ+eLnEMFC6jO/ FTrhB+P95hEF2HFnOpsXQlopiTR+sj3TzIq3IWYIhYiEk24l1Dk2PCVZEPytKGaZR48V l5cg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p12-v6si1810764plr.131.2018.04.11.13.06.31; Wed, 11 Apr 2018 13:07:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756763AbeDKT7y (ORCPT + 99 others); Wed, 11 Apr 2018 15:59:54 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:35856 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756232AbeDKS4h (ORCPT ); Wed, 11 Apr 2018 14:56:37 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id ECEF539; Wed, 11 Apr 2018 18:56:36 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , "Peter Zijlstra (Intel)" , Alexander Shishkin , Arnaldo Carvalho de Melo , Arnaldo Carvalho de Melo , Jiri Olsa , Linus Torvalds , Stephane Eranian , Thomas Gleixner , Vince Weaver , Ingo Molnar , Sasha Levin Subject: [PATCH 4.9 092/310] perf/core: Fix error handling in perf_event_alloc() Date: Wed, 11 Apr 2018 20:33:51 +0200 Message-Id: <20180411183626.202918527@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180411183622.305902791@linuxfoundation.org> References: <20180411183622.305902791@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dan Carpenter [ Upstream commit 36cc2b9222b5106de34085c4dd8635ac67ef5cba ] We don't set an error code here which means that perf_event_alloc() returns ERR_PTR(0) (in other words NULL). The callers are not expecting that and would Oops. Signed-off-by: Dan Carpenter Signed-off-by: Peter Zijlstra (Intel) Cc: Alexander Shishkin Cc: Arnaldo Carvalho de Melo Cc: Arnaldo Carvalho de Melo Cc: Jiri Olsa Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Stephane Eranian Cc: Thomas Gleixner Cc: Vince Weaver Fixes: 375637bc5249 ("perf/core: Introduce address range filtering") Link: http://lkml.kernel.org/r/20170522090418.hvs6icgpdo53wkn5@mwanda Signed-off-by: Ingo Molnar Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- kernel/events/core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -9289,8 +9289,10 @@ perf_event_alloc(struct perf_event_attr event->addr_filters_offs = kcalloc(pmu->nr_addr_filters, sizeof(unsigned long), GFP_KERNEL); - if (!event->addr_filters_offs) + if (!event->addr_filters_offs) { + err = -ENOMEM; goto err_per_task; + } /* force hw sync on the address filters */ event->addr_filters_gen = 1;