aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2023-07-18 15:01:14 +0200
committerHarald Welte <laforge@osmocom.org>2023-07-18 15:01:14 +0200
commit03fd41335a86f9447bfcb11303a4246994b3061c (patch)
tree551312530a298c1037762ef2660dd0153b4a4c42
parente36dbcbc03fcc1c70d098a8c2330b2e293b70de3 (diff)
gtp_tunnel: Avoid double-unlock in error path of gtp_tunnel_alloc
Fixes: CID#307509: Double unlock (LOCK) Change-Id: Ie6e4c08d2c235fbe90516c3dfe2c82963fd70a6f
-rw-r--r--daemon/gtp_tunnel.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/daemon/gtp_tunnel.c b/daemon/gtp_tunnel.c
index f9075f7..87d1e69 100644
--- a/daemon/gtp_tunnel.c
+++ b/daemon/gtp_tunnel.c
@@ -28,7 +28,7 @@ struct gtp_tunnel *gtp_tunnel_alloc(struct gtp_daemon *d, const struct gtp_tunne
t = talloc_zero(d, struct gtp_tunnel);
if (!t)
- goto out_unlock;
+ goto out;
t->d = d;
t->name = talloc_asprintf(t, "%s-R%08x-T%08x", cpars->tun_name, cpars->rx_teid, cpars->tx_teid);
t->tun_dev = tun_device_find_or_create(d, cpars->tun_name, cpars->tun_netns_name);
@@ -72,14 +72,13 @@ struct gtp_tunnel *gtp_tunnel_alloc(struct gtp_daemon *d, const struct gtp_tunne
return t;
out_ep:
+ pthread_rwlock_unlock(&d->rwlock);
_gtp_endpoint_release(t->gtp_ep);
out_tun:
_tun_device_release(t->tun_dev);
out_free:
talloc_free(t);
-out_unlock:
- pthread_rwlock_unlock(&d->rwlock);
-
+out:
return NULL;
}