Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zebra: Fix coverity issue in dplane_srv6_encap_srcaddr_set #15087

Merged
merged 1 commit into from
Jan 5, 2024

Conversation

cscarpitta
Copy link
Contributor

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.

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 <[email protected]>
@frrbot frrbot bot added the zebra label Jan 4, 2024
@donaldsharp donaldsharp merged commit 75490f2 into FRRouting:master Jan 5, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants