Kernel-Janitors Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v2 2/2] perf/core: fix error handling in perf_event_alloc()
@ 2017-05-22  9:04 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2017-05-22  9:04 UTC (permalink / raw)
  To: kernel-janitors

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")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2: split up the patch

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 13f5b942580b..4c24bc4c8a63 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -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;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-22  9:04 [PATCH v2 2/2] perf/core: fix error handling in perf_event_alloc() Dan Carpenter

Kernel-Janitors Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/kernel-janitors/0 kernel-janitors/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 kernel-janitors kernel-janitors/ https://lore.kernel.org/kernel-janitors \
		kernel-janitors@vger.kernel.org
	public-inbox-index kernel-janitors

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.kernel-janitors


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git