aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlexander Couzens <lynxis@fe80.eu>2021-02-02 11:26:17 +0100
committerlaforge <laforge@osmocom.org>2021-02-02 11:39:30 +0000
commit265a5ebac8f755a031ae5f7d83a9ead5226d99b5 (patch)
treeb75aa6233a6a814ee23dbc478d081e44796965ba /src
parent9bbb703a95d8275076e7da702e9740aa978f17bd (diff)
gprs_ns2: prevent division by zero in load_sharing
Check if the NSE is alive before passing UNITDATA to the load sharing. Change-Id: I0e2a59bec9b72f74eb64510a2e1ad60486694a55 Fixes: OS#4996
Diffstat (limited to 'src')
-rw-r--r--src/gb/gprs_ns2.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/gb/gprs_ns2.c b/src/gb/gprs_ns2.c
index 1cf2335f..de27fb40 100644
--- a/src/gb/gprs_ns2.c
+++ b/src/gb/gprs_ns2.c
@@ -365,9 +365,13 @@ static struct gprs_ns2_vc *ns2_load_sharing_modulor(
uint32_t load_selector)
{
struct gprs_ns2_vc *tmp;
- uint32_t mod = (bvci + load_selector) % nse->nsvc_count;
+ uint32_t mod;
uint32_t i = 0;
+ if (nse->nsvc_count == 0)
+ return NULL;
+
+ mod = (bvci + load_selector) % nse->nsvc_count;
llist_for_each_entry(tmp, &nse->nsvc, list) {
if (!ns2_vc_is_unblocked(tmp))
continue;
@@ -457,6 +461,9 @@ int gprs_ns2_recv_prim(struct gprs_ns2_inst *nsi, struct osmo_prim_hdr *oph)
if (!nse)
return -EINVAL;
+ if (!nse->alive)
+ return 0;
+
nsvc = ns2_load_sharing(nse, bvci, nsp->u.unitdata.link_selector);
/* TODO: send a status primitive back */