bsc: Fix possible crash when the lchan->conn alloc failed
Another null pointer dereference found by clang.
diff --git a/openbsc/src/bsc_api.c b/openbsc/src/bsc_api.c
index a9e5f71..87ab981 100644
--- a/openbsc/src/bsc_api.c
+++ b/openbsc/src/bsc_api.c
@@ -478,9 +478,12 @@
} else {
rc = BSC_API_CONN_POL_REJECT;
lchan->conn = subscr_con_allocate(msg->lchan);
+ if (!lchan->conn) {
+ lchan_release(lchan, 0, 0);
+ return -1;
+ }
- if (lchan->conn)
- rc = api->compl_l3(lchan->conn, msg, 0);
+ rc = api->compl_l3(lchan->conn, msg, 0);
if (rc != BSC_API_CONN_POL_ACCEPT) {
lchan->conn->lchan = NULL;