perf: Do not allow optimized switch for non-cloned events
[platform/adaptation/renesas_rcar/renesas_kernel.git] / kernel / events / core.c
index 0e7fea7..f774e93 100644 (file)
@@ -2311,7 +2311,7 @@ static void perf_event_context_sched_out(struct task_struct *task, int ctxn,
        next_parent = rcu_dereference(next_ctx->parent_ctx);
 
        /* If neither context have a parent context; they cannot be clones. */
-       if (!parent && !next_parent)
+       if (!parent || !next_parent)
                goto unlock;
 
        if (next_parent == ctx || next_ctx == parent || next_parent == parent) {