linux-cp: Fix coverity issue 38/35138/3
authorPim van Pelt <pim@ipng.nl>
Fri, 28 Jan 2022 14:29:21 +0000 (14:29 +0000)
committerMatthew Smith <mgsmith@netgate.com>
Fri, 28 Jan 2022 16:46:12 +0000 (16:46 +0000)
Type: fix

Possible negative return in open(), do not use curr_ns_fd if it is
negative.  Addresses Coverity issue 248535

Signed-off-by: Pim van Pelt <pim@ipng.nl>
Change-Id: I8429ede0f1fe9fe6619e3c4dbd83adb620ea62c2

src/plugins/linux-cp/lcp_nl.c

index 8a55f4c..1c0ca0d 100644 (file)
@@ -496,7 +496,7 @@ lcp_nl_open_socket (void)
 
   nl_connect (nm->sk_route, NETLINK_ROUTE);
 
-  if (dest_ns_fd)
+  if (dest_ns_fd && curr_ns_fd >= 0)
     {
       setns (curr_ns_fd, CLONE_NEWNET);
       close (curr_ns_fd);