aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Couzens <lynxis@fe80.eu>2020-12-09 22:02:55 +0100
committerAlexander Couzens <lynxis@fe80.eu>2020-12-15 11:57:16 +0100
commit3326ba7d4c046ed4dcd4946cb354e18a99e139dc (patch)
treef77f29fb029f76881a38fd4ac38c28b58f9e9add
parentb6b2f14197ff9bf7850501e055e6ed79e6f722b7 (diff)
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@ubuntu.com> Signed-off-by: Alexander Couzens <lynxis@fe80.eu> Change-Id: I86b3652d46bdd581fe6cbab16b52395a0daaa082
-rw-r--r--src/sgsn/gprs_subscriber.c6
-rw-r--r--src/sgsn/sgsn_vty.c4
2 files changed, 10 insertions, 0 deletions
diff --git a/src/sgsn/gprs_subscriber.c b/src/sgsn/gprs_subscriber.c
index c23b332f..943fbc3d 100644
--- a/src/sgsn/gprs_subscriber.c
+++ b/src/sgsn/gprs_subscriber.c
@@ -870,6 +870,8 @@ struct gprs_subscr *gprs_subscr_get_or_create_by_mmctx(struct sgsn_mm_ctx *mmctx
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 @@ int gprs_subscr_request_update_location(struct sgsn_mm_ctx *mmctx)
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 @@ int gprs_subscr_request_auth_info(struct sgsn_mm_ctx *mmctx,
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 33a652c9..fee328e7 100644
--- a/src/sgsn/sgsn_vty.c
+++ b/src/sgsn/sgsn_vty.c
@@ -1020,6 +1020,10 @@ DEFUN(update_subscr_create, update_subscr_create_cmd,
}
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);