diff --git a/src/libosmo-mgcp-client/mgcp_client_endpoint_fsm.c b/src/libosmo-mgcp-client/mgcp_client_endpoint_fsm.c index 2259788c9..ef4da1734 100644 --- a/src/libosmo-mgcp-client/mgcp_client_endpoint_fsm.c +++ b/src/libosmo-mgcp-client/mgcp_client_endpoint_fsm.c @@ -255,6 +255,9 @@ struct osmo_mgcpc_ep *osmo_mgcpc_ep_fi_mgwep(struct osmo_fsm_inst *fi) * MGCP messages to set up the endpoint will be sent on the given mgcp_client, as soon as the first * osmo_mgcpc_ep_ci_request() is invoked. * + * IMPORTANT: To avoid use-after-free problems, using this FSM requires use of deferred FSM deallocation using + * osmo_fsm_set_dealloc_ctx(), e.g. using osmo_select_main_ctx(OTC_SELECT) with osmo_select_main_ctx() as main loop. + * * A typical sequence of events would be: * * ep = osmo_mgcpc_ep_alloc(..., mgcp_client_rtpbridge_wildcard(client)); diff --git a/src/libosmo-mgcp-client/mgcp_client_fsm.c b/src/libosmo-mgcp-client/mgcp_client_fsm.c index 7565d3283..800ae1bc7 100644 --- a/src/libosmo-mgcp-client/mgcp_client_fsm.c +++ b/src/libosmo-mgcp-client/mgcp_client_fsm.c @@ -708,6 +708,9 @@ void mgcp_conn_delete(struct osmo_fsm_inst *fi) OSMO_ASSERT(mgcp_ctx); + if (fi->proc.terminating) + return; + /* Unlink FSM from parent */ osmo_fsm_inst_unlink_parent(fi, NULL);