Hi all,

Prevent crash introduced in the a9fae1ae commit.
Call "show network" in the NITB VTY without any BTS connected to
reproduce the crash.

Before it was stored in a local variable, but accessed from a net
structure in the msc_signal_handler().


-- 
Regards,
Alexander Chemeris.
CEO, Fairwaves, Inc. / ООО УмРадио
https://fairwaves.co
From 956ec6f462ba0139ba959c13f2d934954dede3c4 Mon Sep 17 00:00:00 2001
From: Alexander Chemeris <[email protected]>
Date: Thu, 6 Mar 2014 15:35:22 +0100
Subject: [PATCH] bsc,nitb: Store rf_ctrl in the net structure in osmo-nitb.

Prevent crash introduced in the a9fae1ae commit.
Call "show network" in the NITB VTY without any BTS connected to reproduce the crash.

Before it was stored in a local variable, but accessed from a net structure in the msc_signal_handler().
---
 openbsc/src/libbsc/bsc_rf_ctrl.c |    3 +++
 openbsc/src/osmo-nitb/bsc_hack.c |    4 +---
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/openbsc/src/libbsc/bsc_rf_ctrl.c b/openbsc/src/libbsc/bsc_rf_ctrl.c
index 0538482..b87c81e 100644
--- a/openbsc/src/libbsc/bsc_rf_ctrl.c
+++ b/openbsc/src/libbsc/bsc_rf_ctrl.c
@@ -525,6 +525,9 @@ struct osmo_bsc_rf *osmo_bsc_rf_create(const char *path, struct gsm_network *net
 	rf->auto_off_timer.data = rf;
 	rf->auto_off_timer.cb = rf_auto_off_cb;
 
+	/* Store the cretaed rf interface */
+	net->bsc_data->rf_ctrl = rf;
+
 	/* listen to RF signals */
 	osmo_signal_register_handler(SS_MSC, msc_signal_handler, net);
 
diff --git a/openbsc/src/osmo-nitb/bsc_hack.c b/openbsc/src/osmo-nitb/bsc_hack.c
index d746bf1..75bbc4c 100644
--- a/openbsc/src/osmo-nitb/bsc_hack.c
+++ b/openbsc/src/osmo-nitb/bsc_hack.c
@@ -52,7 +52,6 @@
 
 /* MCC and MNC for the Location Area Identifier */
 struct gsm_network *bsc_gsmnet = 0;
-static struct osmo_bsc_rf *rf_ctrl;
 static const char *database_name = "hlr.sqlite3";
 static const char *config_file = "openbsc.cfg";
 static const char *rf_ctrl_name = NULL;
@@ -298,8 +297,7 @@ int main(int argc, char **argv)
 	/* seed the PRNG */
 	srand(time(NULL));
 
-	rf_ctrl = osmo_bsc_rf_create(rf_ctrl_name, bsc_gsmnet);
-	if (!rf_ctrl) {
+	if (!osmo_bsc_rf_create(rf_ctrl_name, bsc_gsmnet)) {
 		fprintf(stderr, "Failed to create the RF service.\n");
 		exit(1);
 	}
-- 
1.7.9.5

Reply via email to