From abf962b0963d17551c31b7c420669287c494a9de Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Sun, 14 Nov 2010 16:04:46 +0100 Subject: [PATCH] bsc_api: Clear lchan->conn on lchan_release Set conn to NULL before starting the release procedure, remove code to check for a lchan->conn as it can not happen. If there are any memleaks we will notice them. Detach the lchan->conn from the channel before detaching. --- openbsc/src/bsc_api.c | 4 +--- openbsc/src/chan_alloc.c | 9 +-------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/openbsc/src/bsc_api.c b/openbsc/src/bsc_api.c index 59b6af818..f1f7a626d 100644 --- a/openbsc/src/bsc_api.c +++ b/openbsc/src/bsc_api.c @@ -368,10 +368,8 @@ int gsm0808_clear(struct gsm_subscriber_connection *conn) if (conn->ho_lchan) bsc_clear_handover(conn); - if (conn->lchan) { + if (conn->lchan) lchan_release(conn->lchan, 1, 0); - conn->lchan->conn = NULL; - } conn->lchan = NULL; conn->ho_lchan = NULL; diff --git a/openbsc/src/chan_alloc.c b/openbsc/src/chan_alloc.c index 2cdd9927b..ff5600bf3 100644 --- a/openbsc/src/chan_alloc.c +++ b/openbsc/src/chan_alloc.c @@ -281,13 +281,6 @@ struct gsm_lchan *lchan_alloc(struct gsm_bts *bts, enum gsm_chan_t type, /* clear multi rate config */ memset(&lchan->mr_conf, 0, sizeof(lchan->mr_conf)); - - /* clear per MSC/BSC data */ - if (lchan->conn) { - LOGP(DRLL, LOGL_ERROR, "lchan->conn should be NULL.\n"); - subscr_con_free(lchan->conn); - lchan->conn = NULL; - } } else { struct challoc_signal_data sig; sig.bts = bts; @@ -338,7 +331,6 @@ void lchan_free(struct gsm_lchan *lchan) if (lchan->conn) { LOGP(DRLL, LOGL_ERROR, "the subscriber connection should be gone.\n"); - subscr_con_free(lchan->conn); lchan->conn = NULL; } @@ -422,6 +414,7 @@ int lchan_release(struct gsm_lchan *lchan, int sach_deact, int reason) DEBUGP(DRLL, "%s starting release sequence\n", gsm_lchan_name(lchan)); rsl_lchan_set_state(lchan, LCHAN_S_REL_REQ); + lchan->conn = NULL; lchan->release_reason = reason; lchan->sach_deact = sach_deact; _lchan_handle_release(lchan);