[PATCH] perf_events: fix NULL point in free_event()

From: Stephane Eranian
Date: Mon Sep 13 2010 - 10:38:40 EST


Without the following patch, perf top as non-root and
paranoid cpu set causes a NULL pointer dereference in
free_event() because event->ctx is NULL.

free_event() may be called, on the error path, before
event->ctx is set.

Signed-off-by: Stephane Eranian <eranian@xxxxxxxxxx>

diff --git a/kernel/perf_event.c b/kernel/perf_event.c
index f29b525..a7d5e7a 100644
--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -2150,7 +2150,8 @@ static void free_event(struct perf_event *event)
if (event->destroy)
event->destroy(event);

- put_ctx(event->ctx);
+ if (event->ctx)
+ put_ctx(event->ctx);
call_rcu(&event->rcu_head, free_event_rcu);
}

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/