Fix session/tcp coverity warnings 76/10276/3
authorFlorin Coras <fcoras@cisco.com>
Fri, 26 Jan 2018 09:27:01 +0000 (01:27 -0800)
committerDamjan Marion <dmarion.lists@gmail.com>
Sat, 27 Jan 2018 10:51:10 +0000 (10:51 +0000)
Change-Id: I5c404eacb4a6c1e16485a6656168d9171ff49a8b
Signed-off-by: Florin Coras <fcoras@cisco.com>
src/vnet/session/session_api.c
src/vnet/session/transport.c
src/vnet/tcp/tcp_debug.h

index 5201ec6..a1225f8 100755 (executable)
@@ -354,6 +354,10 @@ vl_api_application_attach_t_handler (vl_api_application_attach_t * mp)
   clib_error_t *error = 0;
   int rv = 0;
 
+  reg = vl_api_client_index_to_registration (mp->client_index);
+  if (!reg)
+    return;
+
   if (session_manager_is_enabled () == 0)
     {
       rv = VNET_API_ERROR_FEATURE_DISABLED;
@@ -410,8 +414,6 @@ done:
   if (rv)
     return;
 
-  reg = vl_api_client_index_to_registration (mp->client_index);
-
   /* Send fifo segment fd if needed */
   if (ssvm_type (a->segment) == SSVM_SEGMENT_MEMFD)
     session_send_memfd_fd (reg, a->segment);
index c31964c..acbb4f6 100644 (file)
@@ -310,6 +310,13 @@ transport_alloc_local_endpoint (u8 proto, transport_endpoint_t * rmt,
     {
       ip4_address_t *ip4;
       ip4 = ip_interface_get_first_ip (sw_if_index, 1);
+      if (!ip4)
+       {
+         clib_warning ("no routable ip4 address on %U",
+                       format_vnet_sw_if_index_name, vnet_get_main (),
+                       sw_if_index);
+         return -1;
+       }
       lcl_addr->ip4.as_u32 = ip4->as_u32;
     }
   else
index 5d4f7d6..e37b3cd 100755 (executable)
@@ -328,15 +328,18 @@ typedef enum _tcp_dbg_evt
 
 #define TCP_EVT_RST_SENT_HANDLER(_tc, ...)                             \
 {                                                                      \
-  ELOG_TYPE_DECLARE (_e) =                                             \
+if (_tc)                                                               \
   {                                                                    \
-    .format = "rst-tx: snd_nxt %d rcv_nxt %d",                         \
-    .format_args = "i4i4",                                             \
-  };                                                                   \
-  DECLARE_ETD(_tc, _e, 2);                                             \
-  ed->data[0] = _tc->snd_nxt - _tc->iss;                               \
-  ed->data[1] = _tc->rcv_nxt - _tc->irs;                               \
-  TCP_EVT_STATE_CHANGE_HANDLER(_tc);                                   \
+    ELOG_TYPE_DECLARE (_e) =                                           \
+    {                                                                  \
+      .format = "rst-tx: snd_nxt %d rcv_nxt %d",                       \
+      .format_args = "i4i4",                                           \
+    };                                                                 \
+    DECLARE_ETD(_tc, _e, 2);                                           \
+    ed->data[0] = _tc->snd_nxt - _tc->iss;                             \
+    ed->data[1] = _tc->rcv_nxt - _tc->irs;                             \
+    TCP_EVT_STATE_CHANGE_HANDLER(_tc);                                 \
+  }                                                                    \
 }
 
 #define TCP_EVT_FIN_RCVD_HANDLER(_tc, ...)                             \