From: Dan Carpenter Date: Mon, 22 May 2017 09:04:18 +0000 (+0300) Subject: perf/core: Fix error handling in perf_event_alloc() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=36cc2b9222b5106de34085c4dd8635ac67ef5cba;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git perf/core: Fix error handling in perf_event_alloc() 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 --- diff --git a/kernel/events/core.c b/kernel/events/core.c index 0028efa0abc3..f8c27d3ef3a1 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -9469,8 +9469,10 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu, 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;