From 33b0bee457d335266f91e4c2876639c5f6f97940 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Tue, 6 Apr 2010 17:43:12 +0200 Subject: bsc_msc_ip.c: Crash fix when the MSC disconnects Check if we do have the msc_data before invoking code in bssap.c. We might have lost the MSC connection and asked for the channel to be taken down but we might have received one last message from the BTS. --- openbsc/src/bsc_msc_ip.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'openbsc/src/bsc_msc_ip.c') diff --git a/openbsc/src/bsc_msc_ip.c b/openbsc/src/bsc_msc_ip.c index 5976a0292..9412627a2 100644 --- a/openbsc/src/bsc_msc_ip.c +++ b/openbsc/src/bsc_msc_ip.c @@ -297,6 +297,11 @@ static int handle_cipher_m_complete(struct msgb *msg) { struct msgb *resp; + if (!msg->lchan->msc_data) { + LOGP(DMSC, LOGL_ERROR, "No MSC data for CIPHER MODE COMPLETE.\n"); + return -1; + } + DEBUGP(DMSC, "CIPHER MODE COMPLETE from MS, forwarding to MSC\n"); resp = bssmap_create_cipher_complete(msg); if (!resp) { @@ -320,7 +325,7 @@ static int handle_ass_compl(struct msgb *msg) DEBUGP(DMSC, "ASSIGNMENT COMPLETE from MS, forwarding to MSC\n"); if (!msg->lchan->msc_data) { - DEBUGP(DMSC, "No MSC data\n"); + LOGP(DMSC, LOGL_ERROR, "No MSC data\n"); put_lchan(msg->lchan, 0); return -1; } @@ -367,7 +372,7 @@ static int handle_ass_fail(struct msgb *msg) DEBUGP(DMSC, "ASSIGNMENT FAILURE from MS, forwarding to MSC\n"); if (!msg->lchan->msc_data) { - DEBUGP(DMSC, "No MSC data\n"); + LOGP(DMSC, LOGL_ERROR, "No MSC data\n"); put_lchan(msg->lchan, 0); return -1; } @@ -398,6 +403,11 @@ static int handle_modify_ack(struct msgb *msg) { int rc; + if (!msg->lchan->msc_data) { + LOGP(DMSC, LOGL_ERROR, "No MSC data for modify ack.\n"); + return -1; + } + /* modify RSL */ rc = gsm48_rx_rr_modif_ack(msg); if (rc < 0) -- cgit v1.2.3