summaryrefslogtreecommitdiff
path: root/zebra/zebra_dplane.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@nvidia.com>2023-05-05 19:03:40 -0400
committerDonald Sharp <sharpd@nvidia.com>2023-05-05 19:11:02 -0400
commit3e7b3ed1dc4dd37120b4bb791790792ac484f5ef (patch)
tree09b46319318b9a79b5e62b968ead5974b4f8d2c9 /zebra/zebra_dplane.c
parent6636fc44c8ffa72061abaef710e3e773f41c6e4f (diff)
zebra: dplane_gre_set could return while leaking ctx
Prevent this function from leaking the ctx memory. Also properly record that something has gone wrong. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Diffstat (limited to 'zebra/zebra_dplane.c')
-rw-r--r--zebra/zebra_dplane.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/zebra/zebra_dplane.c b/zebra/zebra_dplane.c
index e78cd3b1d0..a3b61c9049 100644
--- a/zebra/zebra_dplane.c
+++ b/zebra/zebra_dplane.c
@@ -5303,8 +5303,10 @@ dplane_gre_set(struct interface *ifp, struct interface *ifp_link,
ctx = dplane_ctx_alloc();
- if (!ifp)
- return result;
+ if (!ifp) {
+ ret = EINVAL;
+ goto done;
+ }
if (IS_ZEBRA_DEBUG_DPLANE_DETAIL) {
zlog_debug("init dplane ctx %s: if %s link %s%s",
@@ -5316,8 +5318,11 @@ dplane_gre_set(struct interface *ifp, struct interface *ifp_link,
ctx->zd_op = op;
ctx->zd_status = ZEBRA_DPLANE_REQUEST_SUCCESS;
zns = zebra_ns_lookup(ifp->vrf->vrf_id);
- if (!zns)
- return result;
+ if (!zns) {
+ ret = EINVAL;
+ goto done;
+ }
+
dplane_ctx_ns_init(ctx, zns, false);
dplane_ctx_set_ifname(ctx, ifp->name);
@@ -5336,6 +5341,7 @@ dplane_gre_set(struct interface *ifp, struct interface *ifp_link,
/* Enqueue context for processing */
ret = dplane_update_enqueue(ctx);
+done:
/* Update counter */
atomic_fetch_add_explicit(&zdplane_info.dg_gre_set_in, 1,
memory_order_relaxed);