aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Maier <pmaier@sysmocom.de>2017-06-26 17:28:43 +0200
committerHarald Welte <laforge@gnumonks.org>2017-06-28 13:21:51 +0000
commit5047fbe3b8b9e1e2404c7c8952ae2ac7a0ada662 (patch)
treeb901f37e5d3ef35df75a4526787e3ede0d034fb7
parent521ab50dcc95a7f0626340b76f9803805ee09bfc (diff)
octphy: initalize nmsg only when needed
nmsg is initalized every time the function runs, even when it is not needed. Move the initalization into the if (msg) body so that nmsg is only initalized when we really need it. (Patch by Octasic Inc.) Change-Id: If51dc50a9f4bdb4aba62c0ae5fbfac552806f0c0
-rw-r--r--src/osmo-bts-octphy/l1_if.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/osmo-bts-octphy/l1_if.c b/src/osmo-bts-octphy/l1_if.c
index 9b348a9c..0efc4bb4 100644
--- a/src/osmo-bts-octphy/l1_if.c
+++ b/src/osmo-bts-octphy/l1_if.c
@@ -584,13 +584,14 @@ static int ph_tch_req(struct gsm_bts_trx *trx, struct msgb *msg,
lchan = get_lchan_by_chan_nr(trx, chan_nr);
- /* create new message */
- nmsg = l1p_msgb_alloc();
- if (!nmsg)
- return -ENOMEM;
-
/* create new message and fill data */
if (msg) {
+ nmsg = l1p_msgb_alloc();
+ if (!nmsg) {
+ LOGP(DL1C, LOGL_FATAL, "L1SAP PH-TCH.req msg alloc failed\n");
+ return -ENOMEM;
+ }
+
msgb_pull(msg, sizeof(*l1sap));
tOCTVC1_GSM_MSG_TRX_REQUEST_LOGICAL_CHANNEL_DATA_CMD *data_req =
(tOCTVC1_GSM_MSG_TRX_REQUEST_LOGICAL_CHANNEL_DATA_CMD *)