Skip to content

Commit 41aab00

Browse files
markovicbudimirsfX-bot
authored andcommitted
perf: Fix check before add_event_to_groups() in perf_group_detach()
Events should only be added to a groups rb tree if they have not been removed from their context by list_del_event(). Since remove_on_exec made it possible to call list_del_event() on individual events before they are detached from their group, perf_group_detach() should check each sibling's attach_state before calling add_event_to_groups() on it. Fixes: 2e498d0a74e5 ("perf: Add support for event removal on exec") Signed-off-by: Budimir Markovic <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lkml.kernel.org/r/ZBFzvQV9tEqoHEtH@gentoo
1 parent 52d199a commit 41aab00

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/events/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2259,7 +2259,7 @@ static void perf_group_detach(struct perf_event *event)
22592259
/* Inherit group flags from the previous leader */
22602260
sibling->group_caps = event->group_caps;
22612261

2262-
if (!RB_EMPTY_NODE(&event->group_node)) {
2262+
if (sibling->attach_state & PERF_ATTACH_CONTEXT) {
22632263
add_event_to_groups(sibling, event->ctx);
22642264

22652265
if (sibling->state == PERF_EVENT_STATE_ACTIVE)

0 commit comments

Comments
 (0)