aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2020-10-09 14:20:13 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2020-10-09 14:20:13 +0200
commitaa83d4110b4bac0f5e9aeb21f65404fd14a5f671 (patch)
tree66f6e64a7778ec01d1cac873579c9ab09898fcbd
parentcb11a60d25d87d1576571fb94c6c84d0b1291165 (diff)
gprs_ns2_udp: Avoid dangling freed struct in list if binding fails
-rw-r--r--src/gb/gprs_ns2_udp.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/gb/gprs_ns2_udp.c b/src/gb/gprs_ns2_udp.c
index 3ce05084..207febf7 100644
--- a/src/gb/gprs_ns2_udp.c
+++ b/src/gb/gprs_ns2_udp.c
@@ -303,8 +303,6 @@ int gprs_ns2_ip_bind(struct gprs_ns2_inst *nsi,
priv->addr = *local;
INIT_LLIST_HEAD(&bind->nsvc);
- llist_add(&bind->list, &nsi->binding);
-
rc = osmo_sock_init_osa_ofd(&priv->fd, SOCK_DGRAM, IPPROTO_UDP,
local, NULL,
OSMO_SOCK_F_BIND);
@@ -325,6 +323,7 @@ int gprs_ns2_ip_bind(struct gprs_ns2_inst *nsi,
dscp, rc, errno);
}
+ llist_add(&bind->list, &nsi->binding);
ns2_vty_bind_apply(bind);
if (result)