dexter has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-bsc/+/31673 )


Change subject: pcu_sock: get rid of leaking message buffer
......................................................................

pcu_sock: get rid of leaking message buffer

When a data request is received from the PCU, some of the switch cases
allocate a message buffer but the message buffer is only used to pass
its data and length to other functions. The message buffer itself is not
passed anywhere and it is also not freed. Lets get rid of the message
buffer and avoid unnecessary memcopy calls.

Related: OS#5198
Change-Id: Ibfaae177585a4d42d797b6bbd90e402641620140
---
M src/osmo-bsc/pcu_sock.c
1 file changed, 19 insertions(+), 23 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/73/31673/1

diff --git a/src/osmo-bsc/pcu_sock.c b/src/osmo-bsc/pcu_sock.c
index 3d8c254..fa4193f 100644
--- a/src/osmo-bsc/pcu_sock.c
+++ b/src/osmo-bsc/pcu_sock.c
@@ -532,7 +532,6 @@
 static int pcu_rx_data_req(struct gsm_bts *bts, uint8_t msg_type,
        struct gsm_pcu_if_data *data_req)
 {
-       struct msgb *msg;
        uint32_t tlli = -1;
        uint8_t pag_grp;
        int rc = 0;
@@ -549,18 +548,8 @@
                pcu_rx_rr_paging(bts, pag_grp, data_req->data+3);
                break;
        case PCU_IF_SAPI_AGCH:
-               msg = msgb_alloc(data_req->len, "pcu_agch");
-               if (!msg) {
-                       rc = -ENOMEM;
-                       break;
-               }
-               msg->l3h = msgb_put(msg, data_req->len);
-               memcpy(msg->l3h, data_req->data, data_req->len);
-
-               if (rsl_imm_assign_cmd(bts, msg->len, msg->data)) {
-                       msgb_free(msg);
+               if (rsl_imm_assign_cmd(bts, data_req->len, data_req->data))
                        rc = -EIO;
-               }
                break;
        case PCU_IF_SAPI_PCH_DT:
                /* DT = direct TLLI. A tlli is prefixed so that the BSC/BTS can 
confirm the sending of the downlink
@@ -580,29 +569,20 @@

                LOGP(DPCU, LOGL_DEBUG, "PCU Sends immediate assignment via PCH 
(tlli=0x%08x, pag_grp=0x%02x)\n",
                     tlli, pag_grp);
-               msg = msgb_alloc(data_req->len - 7, "pcu_pch");
-               if (!msg) {
-                       rc = -ENOMEM;
-                       break;
-               }
-               msg->l3h = msgb_put(msg, data_req->len - 7);
-               memcpy(msg->l3h, data_req->data + 7, data_req->len - 7);

                /* NOTE: Sending an IMMEDIATE ASSIGNMENT via PCH became 
necessary with GPRS in order to be able to
                 * assign downlink TBFs directly through the paging channel. 
However, this method never became part
                 * of the RSL specs. This means that each BTS vendor has to 
come up with a proprietary method. At
                 * the moment we only support Ericsson RBS here. */
                if (bts->type == GSM_BTS_TYPE_RBS2000) {
-                       rc = rsl_ericsson_imm_assign_cmd(bts, tlli, msg->len, 
msg->data, pag_grp);
+                       rc = rsl_ericsson_imm_assign_cmd(bts, tlli, 
data_req->len - 7, data_req->data + 7, pag_grp);
                } else {
                        LOGP(DPCU, LOGL_ERROR, "BTS model does not support 
sending immediate assignment via PCH!\n");
                        rc = -ENOTSUP;
                }

-               if (rc) {
-                       msgb_free(msg);
+               if (rc)
                        rc = -EIO;
-               }
                break;
        default:
                LOGP(DPCU, LOGL_ERROR, "Received PCU data request with "

--
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/31673
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: Ibfaae177585a4d42d797b6bbd90e402641620140
Gerrit-Change-Number: 31673
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pma...@sysmocom.de>
Gerrit-MessageType: newchange

Reply via email to