<p>dexter has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/10366">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">sigtran: fix memleak in osmo_bsc_sigtran_send()<br><br>The function osmo_bsc_sigtran_send() checks if the MSC is ready by<br>calling a_reset_conn_ready(). If it is not ready it returns with<br>-EINVAL. The msg message buffer is not freed, so we leak memory in those<br>edge cases.<br><br>- Make sure msg is freed when MSC is not ready.<br>- Add a comment that osmo_bsc_sigtran_send() takes ownership of msg<br><br>Change-Id: Ib1ff1d20e960a356bcee276b7c1bf9c93283e7af<br>---<br>M src/osmo-bsc/osmo_bsc_sigtran.c<br>1 file changed, 2 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/66/10366/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/osmo-bsc/osmo_bsc_sigtran.c b/src/osmo-bsc/osmo_bsc_sigtran.c</span><br><span>index 449f1df..19d4817 100644</span><br><span>--- a/src/osmo-bsc/osmo_bsc_sigtran.c</span><br><span>+++ b/src/osmo-bsc/osmo_bsc_sigtran.c</span><br><span>@@ -338,7 +338,7 @@</span><br><span>   return rc;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-/* Send data to MSC */</span><br><span style="color: hsl(120, 100%, 40%);">+/* Send data to MSC, the function will take ownership of *msg */</span><br><span> int osmo_bsc_sigtran_send(struct gsm_subscriber_connection *conn, struct msgb *msg)</span><br><span> {</span><br><span>      struct osmo_ss7_instance *ss7;</span><br><span>@@ -370,6 +370,7 @@</span><br><span> </span><br><span>     if (a_reset_conn_ready(msc->a.reset_fsm) == false) {</span><br><span>              LOGP(DMSC, LOGL_ERROR, "MSC is not connected. Dropping.\n");</span><br><span style="color: hsl(120, 100%, 40%);">+                msgb_free(msg);</span><br><span>              return -EINVAL;</span><br><span>      }</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/10366">change 10366</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/10366"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-bsc </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Ib1ff1d20e960a356bcee276b7c1bf9c93283e7af </div>
<div style="display:none"> Gerrit-Change-Number: 10366 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: dexter <pmaier@sysmocom.de> </div>