Change in osmo-bsc[master]: coverity: quench null deref warning in gscon_change_primary_lchan()

laforge gerrit-no-reply at
Mon Aug 2 15:02:11 UTC 2021

laforge has submitted this change. ( )

Change subject: coverity: quench null deref warning in gscon_change_primary_lchan()

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
M src/osmo-bsc/bsc_subscr_conn_fsm.c
1 file changed, 4 insertions(+), 2 deletions(-)

  laforge: Looks good to me, approved
  pespin: Looks good to me, but someone else must approve
  Jenkins Builder: Verified

diff --git a/src/osmo-bsc/bsc_subscr_conn_fsm.c b/src/osmo-bsc/bsc_subscr_conn_fsm.c
index 671f065..afb633d 100644
--- a/src/osmo-bsc/bsc_subscr_conn_fsm.c
+++ b/src/osmo-bsc/bsc_subscr_conn_fsm.c
@@ -699,13 +699,15 @@
 	/* 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)
-	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));

To view, visit
To unsubscribe, or for help writing mail filters, visit

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I8859c6cb9b3b15287e339ce4b6815b946965d0d9
Gerrit-Change-Number: 25097
Gerrit-PatchSet: 2
Gerrit-Owner: neels <nhofmeyr at>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at>
Gerrit-Reviewer: pespin <pespin at>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the gerrit-log mailing list