Module Name:    src
Committed By:   pgoyette
Date:           Wed Sep  5 09:26:59 UTC 2018

Modified Files:
        src/sys/kern [pgoyette-compat]: kern_module.c

Log Message:
If a built-in module is "unloaded", release all the resources associated
with the "required" list.  The list will be re-parsed if the module is
later re-enabled.


To generate a diff of this commit:
cvs rdiff -u -r1.130.2.16 -r1.130.2.17 src/sys/kern/kern_module.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/kern/kern_module.c
diff -u src/sys/kern/kern_module.c:1.130.2.16 src/sys/kern/kern_module.c:1.130.2.17
--- src/sys/kern/kern_module.c:1.130.2.16	Tue Sep  4 11:53:46 2018
+++ src/sys/kern/kern_module.c	Wed Sep  5 09:26:59 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_module.c,v 1.130.2.16 2018/09/04 11:53:46 pgoyette Exp $	*/
+/*	$NetBSD: kern_module.c,v 1.130.2.17 2018/09/05 09:26:59 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.130.2.16 2018/09/04 11:53:46 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.130.2.17 2018/09/05 09:26:59 pgoyette Exp $");
 
 #define _MODULE_INTERNAL
 
@@ -1406,8 +1406,16 @@ module_do_unload(const char *name, bool 
 		kmem_free(mod->mod_required, mod->mod_arequired *
 		    sizeof(module_t));
 	if (mod->mod_source == MODULE_SOURCE_KERNEL) {
-		mod->mod_nrequired = 0; /* will be re-parsed */
-		mod->mod_arequired = 0;
+		if (mod_arequired != 0) {
+			/*
+			 * release "required" resources - will be re-parsed
+			 * if the module is re-enabled
+			 */
+			kmem_free(mod->mod_required,
+			    mod->mod_arequired * sizeof(module_t *));
+			mod->mod_nrequired = 0;
+			mod->mod_arequired = 0;
+		}
 		if (load_requires_force)
 			module_require_force(mod);
 		TAILQ_INSERT_TAIL(&module_builtins, mod, mod_chain);

Reply via email to