aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2021-07-29 14:41:37 +0200
committerlaforge <laforge@osmocom.org>2021-08-02 15:02:11 +0000
commite8708af1e138061b78aa5ce50c61dfc0dc1137dd (patch)
tree6b24fa6ea603635d46a9b2291724566ff7d58b51
parentfc842fba246fd22d6bcc6f05d4c297fc8c82f317 (diff)
coverity: quench null deref warning in gscon_change_primary_lchan()
The if conditions for logging an lchan change made it look like new_lchan might actually be NULL, which it never is. So rather pin new_lchan as non-NULL with an assert and simplify the logic. Related: CID#237146 Related: b0d854556dafe885d740346b1b34ab247cb09d56 Change-Id: I8859c6cb9b3b15287e339ce4b6815b946965d0d9
-rw-r--r--src/osmo-bsc/bsc_subscr_conn_fsm.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/osmo-bsc/bsc_subscr_conn_fsm.c b/src/osmo-bsc/bsc_subscr_conn_fsm.c
index 671f065df..afb633dc3 100644
--- a/src/osmo-bsc/bsc_subscr_conn_fsm.c
+++ b/src/osmo-bsc/bsc_subscr_conn_fsm.c
@@ -699,13 +699,15 @@ void gscon_change_primary_lchan(struct gsm_subscriber_connection *conn, struct g
/* On release, do not receive release events that look like the primary lchan is gone. */
struct gsm_lchan *old_lchan = conn->lchan;
+ OSMO_ASSERT(new_lchan);
+
if (old_lchan == new_lchan)
return;
- if (!old_lchan && new_lchan)
+ if (!old_lchan)
LOGPFSML(conn->fi, LOGL_DEBUG, "setting primary lchan for this conn to %s\n",
new_lchan->fi? osmo_fsm_inst_name(new_lchan->fi) : gsm_lchan_name(new_lchan));
- else if (old_lchan && new_lchan)
+ else
LOGPFSML(conn->fi, LOGL_DEBUG, "primary lchan for this conn changes from %s to %s\n",
old_lchan->fi? osmo_fsm_inst_name(old_lchan->fi) : gsm_lchan_name(old_lchan),
new_lchan->fi? osmo_fsm_inst_name(new_lchan->fi) : gsm_lchan_name(new_lchan));