Fix coverity warnings 86/2086/1
authorDave Barach <[email protected]>
Tue, 26 Jul 2016 14:30:50 +0000 (10:30 -0400)
committerDave Barach <[email protected]>
Tue, 26 Jul 2016 14:31:05 +0000 (10:31 -0400)
Change-Id: I37131f2d814a608fe9098daff83ff395f7ce99d7
Signed-off-by: Dave Barach <[email protected]>
svm/svmtool.c
vlib-api/vlibapi/api_shared.c
vlib-api/vlibmemory/memory_vlib.c
vlib-api/vlibsocket/sockclnt_vlib.c
vlib-api/vlibsocket/socksvr_vlib.c
vlib/vlib/cli.c

index c37afbd..545f071 100644 (file)
@@ -164,6 +164,7 @@ svm_map_region_nolock (svm_map_region_args_t * a)
   if (rp->version == 0)
     {
       clib_warning ("rp->version %d not %d", rp->version, SVM_VERSION);
+      munmap (rp, MMAP_PAGESIZE);
       return (0);
     }
   /* Remap now that the region has been placed */
index 18b189e..66f894b 100644 (file)
@@ -780,6 +780,7 @@ vl_msg_api_process_file (vlib_main_t * vm, u8 * filename,
   if (!(statb.st_mode & S_IFREG) || (statb.st_size < sizeof (*hp)))
     {
       vlib_cli_output (vm, "File not plausible: %s\n", filename);
+      close(fd);
       return;
     }
 
@@ -814,6 +815,7 @@ vl_msg_api_process_file (vlib_main_t * vm, u8 * filename,
     {
       vlib_cli_output (vm, "Range (%d, %d) outside file range (0, %d)\n",
                       first_index, last_index, nitems - 1);
+      munmap (hp, file_size);
       return;
     }
   if (hp->wrapped)
index c2c14ac..13b1121 100644 (file)
@@ -1042,7 +1042,12 @@ vl_api_trace_print_file_cmd (vlib_main_t * vm, u32 first, u32 last,
        }
       msg_id = ntohs (msg_id);
 
-      fseek (fp, -2, SEEK_CUR);
+      if (fseek (fp, -2, SEEK_CUR) < 0)
+        {
+          vlib_cli_output (vm, "fseek failed, %s", strerror(errno));
+          fclose(fp);
+          return;
+        }
 
       /* Mild sanity check */
       if (msg_id >= vec_len (am->msg_handlers))
index d173c86..4ae274c 100644 (file)
@@ -114,6 +114,7 @@ sockclnt_open_index (char *client_name, char *hostname, int port)
   if (rv < 0)
     {
       clib_unix_warning ("FIONBIO");
+      close(sockfd);
       return ~0;
     }
 
index e70124d..91c6bfd 100644 (file)
@@ -608,6 +608,7 @@ socksvr_api_init (vlib_main_t * vm)
   rv = listen (sockfd, 5);
   if (rv < 0)
     {
+      close(sockfd);
       return clib_error_return_unix (0, "listen");
     }
 
index 79db99f..5e959a7 100644 (file)
@@ -853,8 +853,11 @@ add_sub_command (vlib_cli_main_t * cm, uword parent_index, uword child_index)
 
       q = hash_get_mem (cm->parse_rule_index_by_name, sub_name);
       if (!q)
-       clib_error ("reference to unknown rule `%%%v' in path `%v'",
-                   sub_name, c->path);
+        {
+          clib_error ("reference to unknown rule `%%%v' in path `%v'",
+                      sub_name, c->path);
+          return;
+        }
 
       hash_set_mem (p->sub_rule_index_by_name, sub_name,
                    vec_len (p->sub_rules));