aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2021-06-06 15:23:22 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2021-06-06 15:33:17 +0200
commit7855bfe9305f2f0c1e92d6a47c389cbb1bb96ff9 (patch)
tree825008f97308930a1885d1e4a1bd15dfc5f0448a
parentglobal: replace rwlock with mtx if never rlocked (diff)
downloadwireguard-freebsd-7855bfe9305f2f0c1e92d6a47c389cbb1bb96ff9.tar.xz
wireguard-freebsd-7855bfe9305f2f0c1e92d6a47c389cbb1bb96ff9.zip
if_wg: do not crash if deiniting before vnet is up
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r--src/if_wg.c5
-rw-r--r--src/wg_cookie.c2
2 files changed, 5 insertions, 2 deletions
diff --git a/src/if_wg.c b/src/if_wg.c
index 73248a677f40..11b8394b9f7d 100644
--- a/src/if_wg.c
+++ b/src/if_wg.c
@@ -3037,7 +3037,10 @@ wg_module_deinit(void)
VNET_ITERATOR_DECL(vnet_iter);
VNET_LIST_RLOCK();
VNET_FOREACH(vnet_iter) {
- if_clone_detach(VNET_VNET(vnet_iter, wg_cloner));
+ struct if_clone *clone = VNET_VNET(vnet_iter, wg_cloner);
+ if (!clone)
+ continue;
+ if_clone_detach(clone);
VNET_VNET(vnet_iter, wg_cloner) = NULL;
}
VNET_LIST_RUNLOCK();
diff --git a/src/wg_cookie.c b/src/wg_cookie.c
index 31bcf7835d79..d87bfe5d6d6d 100644
--- a/src/wg_cookie.c
+++ b/src/wg_cookie.c
@@ -94,11 +94,11 @@ cookie_init(void)
void
cookie_deinit(void)
{
- uma_zdestroy(ratelimit_zone);
ratelimit_deinit(&ratelimit_v4);
#ifdef INET6
ratelimit_deinit(&ratelimit_v6);
#endif
+ uma_zdestroy(ratelimit_zone);
}
void