bsc: Fix a memory leak when the BSC is not allowed to open a connection
When the BSC is refusing to open an outgoing connection the SCCP
connection was leaked. Use the normal free as the socket should
be either closed or disconnected.
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_api.c b/openbsc/src/osmo-bsc/osmo_bsc_api.c
index 1a6d806..d02b0b5 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_api.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_api.c
@@ -24,6 +24,8 @@
#include <osmocom/gsm/protocol/gsm_08_08.h>
#include <osmocom/gsm/gsm0808.h>
+#include <osmocom/sccp/sccp.h>
+
#define return_when_not_connected(conn) \
if (!conn->sccp_con) {\
LOGP(DMSC, LOGL_ERROR, "MSC Connection not present.\n"); \
@@ -102,11 +104,13 @@
conn->bts->cell_identity);
if (!resp) {
LOGP(DMSC, LOGL_DEBUG, "Failed to create layer3 message.\n");
+ sccp_connection_free(conn->sccp_con->sccp);
bsc_delete_connection(conn->sccp_con);
return BSC_API_CONN_POL_REJECT;
}
if (bsc_open_connection(conn->sccp_con, resp) != 0) {
+ sccp_connection_free(conn->sccp_con->sccp);
bsc_delete_connection(conn->sccp_con);
msgb_free(resp);
return BSC_API_CONN_POL_REJECT;