Module Name:    src
Committed By:   riastradh
Date:           Fri Jul 26 18:34:35 UTC 2024

Modified Files:
        src/sys/net: if_wg.c

Log Message:
wg(4): Allow modunload before any interface creation.

The workqueue and pktq are both lazily created, for annoying module
initialization order reasons, so they may not have been created by
the time of modunload.

PR kern/58470


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.92 src/sys/net/if_wg.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/net/if_wg.c
diff -u src/sys/net/if_wg.c:1.91 src/sys/net/if_wg.c:1.92
--- src/sys/net/if_wg.c:1.91	Thu Jul 25 16:45:36 2024
+++ src/sys/net/if_wg.c	Fri Jul 26 18:34:35 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wg.c,v 1.91 2024/07/25 16:45:36 christos Exp $	*/
+/*	$NetBSD: if_wg.c,v 1.92 2024/07/26 18:34:35 riastradh Exp $	*/
 
 /*
  * Copyright (C) Ryota Ozaki <ozaki.ry...@gmail.com>
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.91 2024/07/25 16:45:36 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.92 2024/07/26 18:34:35 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_altq_enabled.h"
@@ -924,8 +924,10 @@ wgdetach(void)
 	}
 
 	/* No interfaces left.  Nuke it.  */
-	workqueue_destroy(wg_wq);
-	pktq_destroy(wg_pktq);
+	if (wg_wq)
+		workqueue_destroy(wg_wq);
+	if (wg_pktq)
+		pktq_destroy(wg_pktq);
 	psref_class_destroy(wg_psref_class);
 
 	return 0;

Reply via email to