summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Luong <sluong@cisco.com>2021-02-15 09:25:10 -0800
committerJohn Lo <lojultra2020@outlook.com>2021-02-23 23:38:08 +0000
commite46bd4cac4b80c553d39dbc2a06e5dd3f8eef671 (patch)
tree449d0fa3de3a35526d1ae68c20adabbca87e4245
parent1a15eb7846c97a8b6b22d068eb35d2a3dba150e6 (diff)
l2: coverity woe in l2_api.c
Coverify complains deref_ptr before null check. deref_ptr: Directly dereferencing pointer reg. 1214 vl_reg = vl_api_client_index_to_registration (reg->client_index); 1215 ALWAYS_ASSERT (vl_reg != NULL); 1216 CID 216104 (#1 of 1): Dereference before null check (REVERSE_INULL) check_after_deref: Null-checking reg suggests that it may be null, but it has already been dereferenced on all paths leading to the check. 1217 if (reg && vl_api_can_send_msg (vl_reg)) I believe the check is for vl_reg instead of reg because vl_reg may be NULL after the call vl_api_client_index_to_registration. Type: fix Signed-off-by: Steven Luong <sluong@cisco.com> Change-Id: Ic4eb2284e65c48396f20d5024a4241c80c70c886
-rw-r--r--src/vnet/l2/l2_api.c43
1 files changed, 20 insertions, 23 deletions
diff --git a/src/vnet/l2/l2_api.c b/src/vnet/l2/l2_api.c
index 70d6eeff424..01e4ed1c5b2 100644
--- a/src/vnet/l2/l2_api.c
+++ b/src/vnet/l2/l2_api.c
@@ -1207,30 +1207,27 @@ l2_arp_term_process (vlib_main_t * vm, vlib_node_runtime_t * rt,
last_event = *event;
last = now;
- /* *INDENT-OFF* */
pool_foreach (reg, vpe_api_main.l2_arp_term_events_registrations)
- {
- vl_api_registration_t *vl_reg;
- vl_reg = vl_api_client_index_to_registration (reg->client_index);
- ALWAYS_ASSERT (vl_reg != NULL);
-
- if (reg && vl_api_can_send_msg (vl_reg))
- {
- vl_api_l2_arp_term_event_t * vevent;
- vevent = vl_msg_api_alloc (sizeof *vevent);
- clib_memset (vevent, 0, sizeof *vevent);
- vevent->_vl_msg_id = htons (VL_API_L2_ARP_TERM_EVENT);
- vevent->client_index = reg->client_index;
- vevent->pid = reg->client_pid;
- ip_address_encode(&event->ip,
- event->type,
- &vevent->ip);
- vevent->sw_if_index = htonl(event->sw_if_index);
- mac_address_encode(&event->mac, vevent->mac);
- vl_api_send_msg (vl_reg, (u8 *) vevent);
- }
- }
- /* *INDENT-ON* */
+ {
+ vl_api_registration_t *vl_reg;
+ vl_reg =
+ vl_api_client_index_to_registration (reg->client_index);
+ ALWAYS_ASSERT (vl_reg != NULL);
+
+ if (vl_reg && vl_api_can_send_msg (vl_reg))
+ {
+ vl_api_l2_arp_term_event_t *vevent;
+ vevent = vl_msg_api_alloc (sizeof *vevent);
+ clib_memset (vevent, 0, sizeof *vevent);
+ vevent->_vl_msg_id = htons (VL_API_L2_ARP_TERM_EVENT);
+ vevent->client_index = reg->client_index;
+ vevent->pid = reg->client_pid;
+ ip_address_encode (&event->ip, event->type, &vevent->ip);
+ vevent->sw_if_index = htonl (event->sw_if_index);
+ mac_address_encode (&event->mac, vevent->mac);
+ vl_api_send_msg (vl_reg, (u8 *) vevent);
+ }
+ }
}
vec_reset_length (l2am->publish_events);
}