From 69682c8deb2e198d65454de9aa23e1159f138a33 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Tue, 25 Jul 2023 11:27:57 +0200 Subject: [PATCH] rua: Fix null ptr access in hnb->llsk.srv At startup, osmo-hnodeb connects the Iuh socket to the HNBGW, and start the LLSK unix socket link_server waiting for lower layers to connect. If for some reason the lower layers don't connect and an Iuh messages arrives which was to be forwarded to LLSK, it would try to access it without first checking if it was already available. This patch adds a check to avoid a crash when accessing the null pointer. Change-Id: I32d8f91b2fc5401ace386e1085c248476228cd18 --- src/osmo-hnodeb/rua.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/osmo-hnodeb/rua.c b/src/osmo-hnodeb/rua.c index e109ae0..d705c7c 100644 --- a/src/osmo-hnodeb/rua.c +++ b/src/osmo-hnodeb/rua.c @@ -115,6 +115,11 @@ static void hnb_rua_cl_handle(struct hnb *hnb, ANY_t *in) ranap_buf_len = ies.ranaP_Message.size; LOGP(DRUA, LOGL_DEBUG, "Rx RUA UDT ranap_len=%zu\n", ranap_buf_len); + if (!hnb->llsk.srv) { + LOGP(DRUA, LOGL_NOTICE, "Discarding rx RUA UDT ranap_len=%zu due to lower layers not available\n", + ranap_buf_len); + goto free_ret; + } LOGP(DLLSK, LOGL_DEBUG, "Tx IUH-UNITDATA.ind ranap_len=%zu\n", ranap_buf_len); iuh_prim = hnb_iuh_makeprim_unitdata_ind(ranap_buf, ranap_buf_len);