Skip to contentSkip to conversation

perf/core: fix error handling in perf_event_alloc()

PATCH New Dan Carpenter 2 participants 2 messages May 22, 2017 – May 23, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 2/2 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.

Fixes 375637bc5249 ("perf/core: Introduce address range filtering")

---
v2: split up the patch

kernel/events/core.c +3 -1
index 13f5b942580b..4c24bc4c8a63 100644
@@ -9476,8 +9474,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;
#1 lore raw

[tip:perf/core] perf/core: Fix error handling in perf_event_alloc()

perf/core: Fix error handling in perf_event_alloc()
Commit-ID:  36cc2b9222b5106de34085c4dd8635ac67ef5cba
Gitweb:     http://git.kernel.org/tip/36cc2b9222b5106de34085c4dd8635ac67ef5cba
Author:     Dan Carpenter <[email protected]>
AuthorDate: Mon, 22 May 2017 12:04:18 +0300
Committer:  Ingo Molnar <[email protected]>
CommitDate: Tue, 23 May 2017 09:50:05 +0200

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.

Cc Alexander Shishkin <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Stephane Eranian <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Vince Weaver <[email protected]>
Fixes 375637bc5249 ("perf/core: Introduce address range filtering")
---
 kernel/events/core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/events/core.c +3 -1
index 0028efa..f8c27d3 100644
@@ -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;