Change in osmo-sgsn[master]: ACL: move allocation check forward in sgsn_acl_add()

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

Max gerrit-no-reply at lists.osmocom.org
Mon Dec 10 13:35:44 UTC 2018


Max has uploaded this change for review. ( https://gerrit.osmocom.org/12225


Change subject: ACL: move allocation check forward in sgsn_acl_add()
......................................................................

ACL: move allocation check forward in sgsn_acl_add()

There's no point in looking up existing ACL if we could not add new
entry anyway due to memory allocation issues. This optimization will
also simplify integrating IMSI sanitizer in follow-up patches.

Change-Id: I5906304fd3c96002ca1fdc649609e5a4d9ca299b
---
M src/gprs/sgsn_auth.c
1 file changed, 3 insertions(+), 4 deletions(-)



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

diff --git a/src/gprs/sgsn_auth.c b/src/gprs/sgsn_auth.c
index 0a39da4..5a62476 100644
--- a/src/gprs/sgsn_auth.c
+++ b/src/gprs/sgsn_auth.c
@@ -60,14 +60,13 @@
 
 int sgsn_acl_add(const char *imsi, struct sgsn_config *cfg)
 {
-	struct imsi_acl_entry *acl;
+	struct imsi_acl_entry *acl = talloc_zero(NULL, struct imsi_acl_entry);
+	if (!acl)
+		return -ENOMEM;
 
 	if (sgsn_acl_lookup(imsi, cfg))
 		return -EEXIST;
 
-	acl = talloc_zero(NULL, struct imsi_acl_entry);
-	if (!acl)
-		return -ENOMEM;
 	osmo_strlcpy(acl->imsi, imsi, sizeof(acl->imsi));
 
 	llist_add(&acl->list, &cfg->imsi_acl);

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

Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5906304fd3c96002ca1fdc649609e5a4d9ca299b
Gerrit-Change-Number: 12225
Gerrit-PatchSet: 1
Gerrit-Owner: Max <msuraev at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181210/cf02a557/attachment.htm>


More information about the gerrit-log mailing list