perf: Fix a race condition in perf_remove_from_context()
[pandora-kernel.git] / kernel / events / core.c
index 14c111c..a11d537 100644 (file)
@@ -1683,6 +1683,16 @@ retry:
         */
        if (ctx->is_active) {
                raw_spin_unlock_irq(&ctx->lock);
+               /*
+                * Reload the task pointer, it might have been changed by
+                * a concurrent perf_event_context_sched_out().
+                */
+               task = ctx->task;
+               /*
+                * Reload the task pointer, it might have been changed by
+                * a concurrent perf_event_context_sched_out().
+                */
+               task = ctx->task;
                goto retry;
        }