From 183208fd113646acbf08973e16ab9224f3f86179 Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Fri, 23 Feb 2024 10:33:51 +0100 Subject: irmd: Fix race between alloc timeout and respond If a flow allocation times out just before the response, there is a short window where the response will still find the flow, but in DEALLOCATED state. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/irmd/reg/reg.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/irmd') diff --git a/src/irmd/reg/reg.c b/src/irmd/reg/reg.c index 731e44b6..87641f1a 100644 --- a/src/irmd/reg/reg.c +++ b/src/irmd/reg/reg.c @@ -1788,7 +1788,12 @@ int reg_respond_alloc(struct flow_info * info, flow = __reg_get_flow(info->id); if (flow == NULL) { - log_err("Flow not found for allocation: %d", info->id); + log_warn("Flow %d already destroyed.", info->id); + goto fail_flow; + } + + if (flow->info.state == FLOW_DEALLOCATED) { + log_warn("Flow %d already deallocated.", info->id); goto fail_flow; } @@ -2090,7 +2095,6 @@ int reg_wait_ipcp_boot(struct ipcp_info * info, ipcp = __reg_get_ipcp(info->pid); - /* Potential race with the reg_respond_flow. */ if (ipcp->info.state == IPCP_INIT) reg_ipcp_update(ipcp, info); -- cgit v1.2.3