aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp <pmaier@sysmocom.de>2017-01-09 12:00:51 +0100
committerdexter <pmaier@sysmocom.de>2017-01-10 14:13:56 +0000
commit563b744b3801bede7b03e48e09edbd9c328862ab (patch)
tree76d1620719c885505ff1dc92639f30a952251454
parent792573dc9747b256e143183cb555b9ef4ca697ef (diff)
RSL: add assertions to check args of public API
The public functions in rsl.c do not check for null pointers, add assertions to catch null pointers early. Change-Id: I63f127ce70a4127180f90238f564b63e355216ec
-rw-r--r--src/common/rsl.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/common/rsl.c b/src/common/rsl.c
index 41dd2ce..a34c455 100644
--- a/src/common/rsl.c
+++ b/src/common/rsl.c
@@ -2008,6 +2008,8 @@ static void osmo_dyn_ts_disconnected(struct gsm_bts_trx_ts *ts)
void cb_ts_disconnected(struct gsm_bts_trx_ts *ts)
{
+ OSMO_ASSERT(ts);
+
switch (ts->pchan) {
case GSM_PCHAN_TCH_F_PDCH:
return ipacc_dyn_pdch_ts_disconnected(ts);
@@ -2093,6 +2095,8 @@ static void osmo_dyn_ts_connected(struct gsm_bts_trx_ts *ts)
void cb_ts_connected(struct gsm_bts_trx_ts *ts)
{
+ OSMO_ASSERT(ts);
+
switch (ts->pchan) {
case GSM_PCHAN_TCH_F_PDCH:
return ipacc_dyn_pdch_ts_connected(ts);
@@ -2105,7 +2109,10 @@ void cb_ts_connected(struct gsm_bts_trx_ts *ts)
void ipacc_dyn_pdch_complete(struct gsm_bts_trx_ts *ts, int rc)
{
- bool pdch_act = ts->flags & TS_F_PDCH_ACT_PENDING;
+ bool pdch_act;
+ OSMO_ASSERT(ts);
+
+ pdch_act = ts->flags & TS_F_PDCH_ACT_PENDING;
if ((ts->flags & TS_F_PDCH_PENDING_MASK) == TS_F_PDCH_PENDING_MASK)
LOGP(DRSL, LOGL_ERROR,
@@ -2256,7 +2263,12 @@ static int rsl_tx_meas_res(struct gsm_lchan *lchan, uint8_t *l3, int l3_len)
int lapdm_rll_tx_cb(struct msgb *msg, struct lapdm_entity *le, void *ctx)
{
struct gsm_lchan *lchan = ctx;
- struct abis_rsl_common_hdr *rh = msgb_l2(msg);
+ struct abis_rsl_common_hdr *rh;
+
+ /* NOTE: Parameter lapdm_entity *le is ignored */
+
+ OSMO_ASSERT(msg);
+ rh = msgb_l2(msg);
if (lchan->state != LCHAN_S_ACTIVE) {
LOGP(DRSL, LOGL_INFO, "%s(%s) is not active . Dropping message.\n",
@@ -2482,15 +2494,22 @@ static int rsl_rx_ipaccess(struct gsm_bts_trx *trx, struct msgb *msg)
int lchan_deactivate(struct gsm_lchan *lchan)
{
+ OSMO_ASSERT(lchan);
+
lchan->ciph_state = 0;
return bts_model_lchan_deactivate(lchan);
}
int down_rsl(struct gsm_bts_trx *trx, struct msgb *msg)
{
- struct abis_rsl_common_hdr *rslh = msgb_l2(msg);
+ struct abis_rsl_common_hdr *rslh;
int ret = 0;
+ OSMO_ASSERT(trx);
+ OSMO_ASSERT(msg);
+
+ rslh = msgb_l2(msg);
+
if (msgb_l2len(msg) < sizeof(*rslh)) {
LOGP(DRSL, LOGL_NOTICE, "RSL message too short\n");
msgb_free(msg);