Skip to content

Commit 226646f

Browse files
Alan-Jowettshankarseal
authored andcommitted
Cleanup map subscription on failure (#4347)
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
1 parent b5de45a commit 226646f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

libs/api/ebpf_api.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4724,14 +4724,17 @@ ebpf_map_subscribe(
47244724
result = EBPF_SUCCESS;
47254725
} else {
47264726
local_async_query_context->async_ioctl_failed = true;
4727+
break;
47274728
}
47284729
}
47294730

47304731
local_subscription->async_query_contexts.insert({cpu_ids[cpu_index], std::move(local_async_query_context)});
47314732
}
47324733

4733-
if (result == EBPF_SUCCESS) {
4734-
*subscription = local_subscription.release();
4734+
*subscription = local_subscription.release();
4735+
if (result != EBPF_SUCCESS) {
4736+
ebpf_map_unsubscribe(*subscription);
4737+
*subscription = nullptr;
47354738
}
47364739

47374740
EBPF_RETURN_RESULT(result);

0 commit comments

Comments
 (0)