Change in libosmocore[master]: gprs_ns2: prevent division by zero in load_sharing

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Tue Feb 2 11:39:30 UTC 2021


laforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/22625 )

Change subject: gprs_ns2: prevent division by zero in load_sharing
......................................................................

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
---
M src/gb/gprs_ns2.c
1 file changed, 8 insertions(+), 1 deletion(-)

Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/gb/gprs_ns2.c b/src/gb/gprs_ns2.c
index 1cf2335..de27fb4 100644
--- a/src/gb/gprs_ns2.c
+++ b/src/gb/gprs_ns2.c
@@ -365,9 +365,13 @@
 		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 @@
 	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 */

-- 
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/22625
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I0e2a59bec9b72f74eb64510a2e1ad60486694a55
Gerrit-Change-Number: 22625
Gerrit-PatchSet: 4
Gerrit-Owner: lynxis lazus <lynxis at fe80.eu>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210202/ef442bdb/attachment.htm>


More information about the gerrit-log mailing list