<p>pespin has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/osmo-pcu/+/18223">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">pdch: rcv_resource_request(): Clarify tbf_free only needed if MS used to exist beforehand<br><br>Variable found is used to always call Guard() on MS to avoid possible<br>unexpected freeing regressions.<br><br>Change-Id: I62f24fe04ca10fca19bedda288fe3ed3ce75413f<br>---<br>M src/pdch.cpp<br>1 file changed, 25 insertions(+), 23 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/23/18223/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/pdch.cpp b/src/pdch.cpp</span><br><span>index 149ca1f..048577d 100644</span><br><span>--- a/src/pdch.cpp</span><br><span>+++ b/src/pdch.cpp</span><br><span>@@ -548,38 +548,41 @@</span><br><span>   struct gprs_rlcmac_sba *sba;</span><br><span> </span><br><span>     if (request->ID.UnionType) {</span><br><span style="color: hsl(0, 100%, 40%);">-         struct gprs_rlcmac_ul_tbf *ul_tbf = NULL;</span><br><span style="color: hsl(0, 100%, 40%);">-               struct gprs_rlcmac_dl_tbf *dl_tbf = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+             struct gprs_rlcmac_ul_tbf *ul_tbf;</span><br><span style="color: hsl(120, 100%, 40%);">+            struct gprs_rlcmac_dl_tbf *dl_tbf;</span><br><span>           uint32_t tlli = request->ID.u.TLLI;</span><br><span>               uint8_t ta = GSM48_TA_INVALID;</span><br><span style="color: hsl(120, 100%, 40%);">+                bool found = true;</span><br><span> </span><br><span>               GprsMs *ms = bts()->ms_by_tlli(tlli);</span><br><span style="color: hsl(0, 100%, 40%);">-                if (!ms)</span><br><span style="color: hsl(120, 100%, 40%);">+              if (!ms) {</span><br><span style="color: hsl(120, 100%, 40%);">+                    found = false;</span><br><span>                       ms = bts()->ms_alloc(0, 0); /* ms class updated later */</span><br><span style="color: hsl(120, 100%, 40%);">+           }</span><br><span> </span><br><span>                /* Keep the ms, even if it gets idle temporarily */</span><br><span>          GprsMs::Guard guard(ms);</span><br><span style="color: hsl(0, 100%, 40%);">-                ul_tbf = ms->ul_tbf();</span><br><span style="color: hsl(0, 100%, 40%);">-               dl_tbf = ms->dl_tbf();</span><br><span style="color: hsl(0, 100%, 40%);">-               ta = ms->ta();</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-           /* We got a RACH so the MS was in packet idle mode and thus</span><br><span style="color: hsl(0, 100%, 40%);">-              * didn't have any active TBFs */</span><br><span style="color: hsl(0, 100%, 40%);">-           if (ul_tbf) {</span><br><span style="color: hsl(0, 100%, 40%);">-                   LOGPTBFUL(ul_tbf, LOGL_NOTICE,</span><br><span style="color: hsl(0, 100%, 40%);">-                            "Got RACH from TLLI=0x%08x while TBF still exists. Killing pending UL TBF\n",</span><br><span style="color: hsl(0, 100%, 40%);">-                                 tlli);</span><br><span style="color: hsl(0, 100%, 40%);">-                        tbf_free(ul_tbf);</span><br><span style="color: hsl(0, 100%, 40%);">-                       ul_tbf = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+                if (found) {</span><br><span style="color: hsl(120, 100%, 40%);">+                  ul_tbf = ms->ul_tbf();</span><br><span style="color: hsl(120, 100%, 40%);">+                     dl_tbf = ms->dl_tbf();</span><br><span style="color: hsl(120, 100%, 40%);">+                     ta = ms->ta();</span><br><span style="color: hsl(120, 100%, 40%);">+                     /* We got a RACH so the MS was in packet idle mode and thus</span><br><span style="color: hsl(120, 100%, 40%);">+                    * didn't have any active TBFs */</span><br><span style="color: hsl(120, 100%, 40%);">+                 if (ul_tbf) {</span><br><span style="color: hsl(120, 100%, 40%);">+                         LOGPTBFUL(ul_tbf, LOGL_NOTICE,</span><br><span style="color: hsl(120, 100%, 40%);">+                                          "Got RACH from TLLI=0x%08x while TBF still exists. Killing pending UL TBF\n",</span><br><span style="color: hsl(120, 100%, 40%);">+                                       tlli);</span><br><span style="color: hsl(120, 100%, 40%);">+                              tbf_free(ul_tbf);</span><br><span style="color: hsl(120, 100%, 40%);">+                     }</span><br><span style="color: hsl(120, 100%, 40%);">+                     if (dl_tbf) {</span><br><span style="color: hsl(120, 100%, 40%);">+                         LOGPTBFUL(dl_tbf, LOGL_NOTICE,</span><br><span style="color: hsl(120, 100%, 40%);">+                                          "Got RACH from TLLI=0x%08x while TBF still exists. Release pending DL TBF\n",</span><br><span style="color: hsl(120, 100%, 40%);">+                                       tlli);</span><br><span style="color: hsl(120, 100%, 40%);">+                              tbf_free(dl_tbf);</span><br><span style="color: hsl(120, 100%, 40%);">+                     }</span><br><span>            }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-           if (dl_tbf) {</span><br><span style="color: hsl(0, 100%, 40%);">-                   LOGPTBFUL(dl_tbf, LOGL_NOTICE,</span><br><span style="color: hsl(0, 100%, 40%);">-                            "Got RACH from TLLI=0x%08x while TBF still exists. Release pending DL TBF\n",</span><br><span style="color: hsl(0, 100%, 40%);">-                                 tlli);</span><br><span style="color: hsl(0, 100%, 40%);">-                        tbf_free(dl_tbf);</span><br><span style="color: hsl(0, 100%, 40%);">-                       dl_tbf = NULL;</span><br><span style="color: hsl(0, 100%, 40%);">-          }</span><br><span>            LOGP(DRLCMAC, LOGL_DEBUG, "MS requests UL TBF "</span><br><span>                    "in packet resource request of single "</span><br><span>                    "block, so we provide one:\n");</span><br><span>@@ -606,12 +609,11 @@</span><br><span>            if (!ms->ms_class())</span><br><span>                      LOGP(DRLCMAC, LOGL_NOTICE, "MS does not give us a class.\n");</span><br><span>              if (ms->egprs_ms_class())</span><br><span style="color: hsl(0, 100%, 40%);">-                    LOGP(DRLCMAC, LOGL_NOTICE,</span><br><span style="color: hsl(120, 100%, 40%);">+                    LOGP(DRLCMAC, LOGL_INFO,</span><br><span>                             "MS supports EGPRS multislot class %d.\n",</span><br><span>                                 ms->egprs_ms_class());</span><br><span> </span><br><span>                ul_tbf = tbf_alloc_ul(bts_data(), ms, trx_no(), tlli, ta);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span>           if (!ul_tbf) {</span><br><span>                       handle_tbf_reject(bts_data(), ms, tlli,</span><br><span>                              trx_no(), ts_no);</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-pcu/+/18223">change 18223</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-pcu/+/18223"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-pcu </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I62f24fe04ca10fca19bedda288fe3ed3ce75413f </div>
<div style="display:none"> Gerrit-Change-Number: 18223 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>