aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/wireguard/wireguard_noise.h
diff options
context:
space:
mode:
authorGabriel Oginski <gabrielx.oginski@intel.com>2022-02-16 12:32:53 +0000
committerFan Zhang <roy.fan.zhang@intel.com>2022-02-18 09:50:41 +0000
commitc810c33f846c2d694ffcd715e917206a9a0a038d (patch)
tree51f8f5f0c4d35b3b82a2f0c5779b9553b1992265 /src/plugins/wireguard/wireguard_noise.h
parent699bea24944907fed5f7516e339aa2eca7c2dd17 (diff)
wireguard: fix passing null pointer
Type: fix Fixed coverity-issue CID 248517. Originally possibly passing null pointer to one function and directly dereferences it. This patch fixes the problem by add a new condition. Signed-off-by: Gabriel Oginski <gabrielx.oginski@intel.com> Change-Id: I02fc6fb5d1cfd6138ea4ba2b1946fd8a7ef34d3b
Diffstat (limited to 'src/plugins/wireguard/wireguard_noise.h')
-rw-r--r--src/plugins/wireguard/wireguard_noise.h20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/plugins/wireguard/wireguard_noise.h b/src/plugins/wireguard/wireguard_noise.h
index e95211b8884..b436120dd8c 100644
--- a/src/plugins/wireguard/wireguard_noise.h
+++ b/src/plugins/wireguard/wireguard_noise.h
@@ -199,22 +199,22 @@ noise_remote_encrypt (vlib_main_t * vm, noise_remote_t *,
static_always_inline noise_keypair_t *
wg_get_active_keypair (noise_remote_t *r, uint32_t r_idx)
{
- if (r->r_current != NULL && r->r_current->kp_local_index == r_idx)
+ if (r->r_current != NULL)
{
- return r->r_current;
+ if (r->r_current->kp_local_index == r_idx)
+ return r->r_current;
}
- else if (r->r_previous != NULL && r->r_previous->kp_local_index == r_idx)
+ if (r->r_previous != NULL)
{
- return r->r_previous;
+ if (r->r_previous->kp_local_index == r_idx)
+ return r->r_previous;
}
- else if (r->r_next != NULL && r->r_next->kp_local_index == r_idx)
+ if (r->r_next != NULL)
{
- return r->r_next;
- }
- else
- {
- return NULL;
+ if (r->r_next->kp_local_index == r_idx)
+ return r->r_next;
}
+ return NULL;
}
inline bool