<p>neels has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/osmo-mgw/+/15898">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">client: endp fsm: clear ci[] before dispatching DLCX success<br><br>In case the ep gets deallocated during event dispatch, move all ci[] cleanup to<br>*before* dispatching a DLCX OK event. Afterwards, it might become a<br>use-after-free.<br><br>Change-Id: Ib2032e5566e465c02a9a525ccd38f9dcc84fb669<br>---<br>M src/libosmo-mgcp-client/mgcp_client_endpoint_fsm.c<br>1 file changed, 6 insertions(+), 2 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/98/15898/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/libosmo-mgcp-client/mgcp_client_endpoint_fsm.c b/src/libosmo-mgcp-client/mgcp_client_endpoint_fsm.c</span><br><span>index 02054ab..30ad2d3 100644</span><br><span>--- a/src/libosmo-mgcp-client/mgcp_client_endpoint_fsm.c</span><br><span>+++ b/src/libosmo-mgcp-client/mgcp_client_endpoint_fsm.c</span><br><span>@@ -663,6 +663,7 @@</span><br><span> {</span><br><span>   int rc;</span><br><span>      struct osmo_mgcpc_ep *ep = ci->ep;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct fsm_notify notify;</span><br><span> </span><br><span>        if (!ci->occupied || !ci->pending || ci->sent)</span><br><span>              return 0;</span><br><span>@@ -701,11 +702,14 @@</span><br><span>                   osmo_mgcp_verb_name(ci->verb), ci->mgcp_ci_str);</span><br><span>                /* The way this is designed, we actually need to forget all about the ci right away. */</span><br><span>              mgcp_conn_delete(ci->mgcp_client_fi);</span><br><span style="color: hsl(0, 100%, 40%);">-                if (ci->notify.fi)</span><br><span style="color: hsl(0, 100%, 40%);">-                   osmo_fsm_inst_dispatch(ci->notify.fi, ci->notify.success, ci->notify.data);</span><br><span style="color: hsl(120, 100%, 40%);">+          notify = ci->notify;</span><br><span>              *ci = (struct osmo_mgcpc_ep_ci){</span><br><span>                     .ep = ep,</span><br><span>            };</span><br><span style="color: hsl(120, 100%, 40%);">+            /* When dispatching an event for this CI, the user may decide to trigger the next request for this conn</span><br><span style="color: hsl(120, 100%, 40%);">+                * right away. So we must be ready with a cleared *ci. */</span><br><span style="color: hsl(120, 100%, 40%);">+             if (notify.fi)</span><br><span style="color: hsl(120, 100%, 40%);">+                        osmo_fsm_inst_dispatch(notify.fi, notify.success, notify.data);</span><br><span>              break;</span><br><span> </span><br><span>   default:</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-mgw/+/15898">change 15898</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/osmo-mgw/+/15898"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-mgw </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Ib2032e5566e465c02a9a525ccd38f9dcc84fb669 </div>
<div style="display:none"> Gerrit-Change-Number: 15898 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: neels <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>