vppinfra: fix socket init netns coverity 80/34080/4
authorFlorin Coras <fcoras@cisco.com>
Tue, 12 Oct 2021 15:52:12 +0000 (08:52 -0700)
committerDamjan Marion <dmarion@me.com>
Wed, 13 Oct 2021 14:30:41 +0000 (14:30 +0000)
Type: fix

Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: I4f37c6601ace08ae886b08d2284b413d457e4eae

src/vppinfra/socket.c

index 2921e00..a09a390 100644 (file)
@@ -563,6 +563,9 @@ clib_socket_init_netns (clib_socket_t *s, u8 *namespace)
   int old_netns_fd, nfd = -1;
 
   old_netns_fd = clib_netns_open (NULL /* self */);
+  if (old_netns_fd < 0)
+    return clib_error_return_unix (0, "get current netns failed");
+
   if ((nfd = clib_netns_open (namespace)) == -1)
     {
       error = clib_error_return_unix (0, "clib_netns_open '%s'", namespace);