Change in osmo-sgsn[master]: sgsn: check for NULL of gprs_subscr_get_or_create()

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/.

lynxis lazus gerrit-no-reply at lists.osmocom.org
Wed Dec 9 21:06:39 UTC 2020


lynxis lazus has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-sgsn/+/21639 )


Change subject: sgsn: check for NULL of gprs_subscr_get_or_create()
......................................................................

sgsn: check for NULL of gprs_subscr_get_or_create()

gprs_subscr_get_or_create() can return NULL if no memory can
be allocated. Detected by the compiler on Ubuntu s390x.

Signed-off-by: Steve Langasek <steve.langasek at ubuntu.com>
Signed-off-by: Alexander Couzens <lynxis at fe80.eu>

Change-Id: I86b3652d46bdd581fe6cbab16b52395a0daaa082
---
M src/sgsn/gprs_subscriber.c
M src/sgsn/sgsn_vty.c
2 files changed, 10 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-sgsn refs/changes/39/21639/1

diff --git a/src/sgsn/gprs_subscriber.c b/src/sgsn/gprs_subscriber.c
index c23b332..943fbc3 100644
--- a/src/sgsn/gprs_subscriber.c
+++ b/src/sgsn/gprs_subscriber.c
@@ -870,6 +870,8 @@
 
 	if (!subscr) {
 		subscr = gprs_subscr_get_or_create(mmctx->imsi);
+		if (!subscr)
+			return NULL;
 		subscr->flags |= GPRS_SUBSCRIBER_FIRST_CONTACT;
 		subscr->flags &= ~GPRS_SUBSCRIBER_ENABLE_PURGE;
 	}
@@ -893,6 +895,8 @@
 	LOGMMCTXP(LOGL_DEBUG, mmctx, "Requesting subscriber data update\n");
 
 	subscr = gprs_subscr_get_or_create_by_mmctx(mmctx);
+	if (!subscr)
+		return -ENOMEM;
 
 	subscr->flags |= GPRS_SUBSCRIBER_UPDATE_LOCATION_PENDING;
 
@@ -918,6 +922,8 @@
 	LOGMMCTXP(LOGL_DEBUG, mmctx, "Requesting subscriber authentication info\n");
 
 	subscr = gprs_subscr_get_or_create_by_mmctx(mmctx);
+	if (!subscr)
+		return -ENOMEM;
 
 	subscr->flags |= GPRS_SUBSCRIBER_UPDATE_AUTH_INFO_PENDING;
 
diff --git a/src/sgsn/sgsn_vty.c b/src/sgsn/sgsn_vty.c
index 33a652c..56aa0c9 100644
--- a/src/sgsn/sgsn_vty.c
+++ b/src/sgsn/sgsn_vty.c
@@ -1020,6 +1020,10 @@
 	}
 
 	subscr = gprs_subscr_get_or_create(imsi);
+	if (subscr) {
+		vty_out(vty, "Can not create subscriber. Out of memory.%s", imsi);
+		return CMD_WARNING;
+	}
 	subscr->keep_in_ram = 1;
 	gprs_subscr_put(subscr);
 

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

Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-Change-Id: I86b3652d46bdd581fe6cbab16b52395a0daaa082
Gerrit-Change-Number: 21639
Gerrit-PatchSet: 1
Gerrit-Owner: lynxis lazus <lynxis at fe80.eu>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20201209/f6e74abe/attachment.htm>


More information about the gerrit-log mailing list