summaryrefslogtreecommitdiff
path: root/zebra/zebra_dplane.c
diff options
context:
space:
mode:
authorCarmine Scarpitta <cscarpit@cisco.com>2024-01-04 11:10:20 +0100
committerCarmine Scarpitta <cscarpit@cisco.com>2024-01-04 11:13:31 +0100
commita061ba2348e208dc08c993e72c1e6d7d0ae0d04a (patch)
treeccef7970608e5f9ba54978df2c92b67fc8fcf399 /zebra/zebra_dplane.c
parent2aef6958f8703b484fef3462180abca9c51eed35 (diff)
zebra: `ctx` has to be non NULL at this point
Fix the following coverity issue: *** CID 1575079: Null pointer dereferences (REVERSE_INULL) /zebra/zebra_dplane.c: 5950 in dplane_srv6_encap_srcaddr_set() 5944 if (ret == AOK) 5945 result = ZEBRA_DPLANE_REQUEST_QUEUED; 5946 else { 5947 atomic_fetch_add_explicit(&zdplane_info 5948 .dg_srv6_encap_srcaddr_set_errors, 5949 1, memory_order_relaxed); CID 1575079: Null pointer dereferences (REVERSE_INULL) Null-checking "ctx" suggests that it may be null, but it has already been dereferenced on all paths leading to the check. 5950 if (ctx) 5951 dplane_ctx_free(&ctx); 5952 } 5953 return result; 5954 } 5955 Remove the pointer check for `ctx`. At this point in the function it has to be non null since we deref'ed it. Additionally the alloc function that creates it cannot fail. Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
Diffstat (limited to 'zebra/zebra_dplane.c')
-rw-r--r--zebra/zebra_dplane.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/zebra/zebra_dplane.c b/zebra/zebra_dplane.c
index 7db52b1923..99693a5874 100644
--- a/zebra/zebra_dplane.c
+++ b/zebra/zebra_dplane.c
@@ -5947,8 +5947,7 @@ dplane_srv6_encap_srcaddr_set(const struct in6_addr *addr, ns_id_t ns_id)
atomic_fetch_add_explicit(&zdplane_info
.dg_srv6_encap_srcaddr_set_errors,
1, memory_order_relaxed);
- if (ctx)
- dplane_ctx_free(&ctx);
+ dplane_ctx_free(&ctx);
}
return result;
}