From 063047ea7cce2001e0d6791f1d0e024616bae2ff Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Wed, 2 Jun 2021 20:28:16 +0200 Subject: fix rc handling in channel_mode_from_lchan() chan_mode_to_rsl_cmod_spd() may actually return negative on error. To be able to check for that, handle the returned value as a signed rc before assigning to the unsigned spd_ind. Related: SYS#5315 OS#4940 CID#236231 Change-Id: I52e13b24ce67e288ff32dbdaa1c1759089926f5c --- src/osmo-bsc/abis_rsl.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/osmo-bsc') diff --git a/src/osmo-bsc/abis_rsl.c b/src/osmo-bsc/abis_rsl.c index 9378ecb87..1fb4c0475 100644 --- a/src/osmo-bsc/abis_rsl.c +++ b/src/osmo-bsc/abis_rsl.c @@ -354,6 +354,7 @@ static int channel_mode_from_lchan(struct rsl_ie_chan_mode *cm, struct gsm_lchan *lchan, const struct channel_mode_and_rate *ch_mode_rate) { + int rc; memset(cm, 0, sizeof(*cm)); /* FIXME: what to do with data calls ? */ @@ -364,11 +365,12 @@ static int channel_mode_from_lchan(struct rsl_ie_chan_mode *cm, cm->dtx_dtu |= RSL_CMOD_DTXd; /* set TCH Speech/Data */ - cm->spd_ind = chan_mode_to_rsl_cmod_spd(ch_mode_rate->chan_mode); - if (cm->spd_ind < 0) { + rc = chan_mode_to_rsl_cmod_spd(ch_mode_rate->chan_mode); + if (rc < 0) { LOGP(DRSL, LOGL_ERROR, "unsupported: chan_mode = 0x%02x\n", ch_mode_rate->chan_mode); - return cm->spd_ind; + return rc; } + cm->spd_ind = rc; switch (lchan->type) { case GSM_LCHAN_SDCCH: -- cgit v1.2.3