]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: guard close() in netns code
authorDavid Lamparter <equinox@opensourcerouting.org>
Wed, 16 Oct 2024 10:42:02 +0000 (12:42 +0200)
committerDavid Lamparter <equinox@opensourcerouting.org>
Wed, 16 Oct 2024 11:30:25 +0000 (13:30 +0200)
clang-SA complains that ns->fd could be invalid.  Add a guard.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
lib/netns_linux.c

index 8fa4bc6fe0f74ec04afc00d757e0d06c49d5d11b..82162abfd4ba6a5d7a024ee728fa48d136597ad7 100644 (file)
@@ -258,7 +258,7 @@ static void ns_disable_internal(struct ns *ns)
                if (ns_master.ns_disable_hook)
                        (*ns_master.ns_disable_hook)(ns);
 
-               if (have_netns())
+               if (have_netns() && ns->fd >= 0)
                        close(ns->fd);
 
                ns->fd = -1;