Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern When importing modules from the boot loader we shou...
details: https://anonhg.NetBSD.org/src/rev/44f959113913
branches: trunk
changeset: 346077:44f959113913
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Thu Jun 23 04:41:03 2016 +0000
description:
When importing modules from the boot loader we should check for duplicate
module names both in the built-in list and in the list of previously
"pushed" modules.
While here, delay allocating the new 'struct module' until we've passed
the duplicate-name checks.
diffstat:
sys/kern/kern_module.c | 28 +++++++++++++++++++---------
1 files changed, 19 insertions(+), 9 deletions(-)
diffs (59 lines):
diff -r 674152a839be -r 44f959113913 sys/kern/kern_module.c
--- a/sys/kern/kern_module.c Thu Jun 23 04:35:35 2016 +0000
+++ b/sys/kern/kern_module.c Thu Jun 23 04:41:03 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_module.c,v 1.111 2016/06/16 23:09:44 pgoyette Exp $ */
+/* $NetBSD: kern_module.c,v 1.112 2016/06/23 04:41:03 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.111 2016/06/16 23:09:44 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.112 2016/06/23 04:41:03 pgoyette Exp $");
#define _MODULE_INTERNAL
@@ -1240,12 +1240,7 @@
module_t *mod;
int error;
- mod = module_newmodule(MODULE_SOURCE_BOOT);
- if (mod == NULL) {
- return ENOMEM;
- }
-
- /* Check for duplicate modules */
+ /* Check for module name same as a built-in module */
__link_set_foreach(mip, modules) {
if (*mip == &module_dummy)
@@ -1253,10 +1248,25 @@
if (strcmp((*mip)->mi_name, name) == 0) {
module_error("module `%s' pushed by boot loader "
"already exists", name);
- kmem_free(mod, sizeof(*mod));
return EEXIST;
}
}
+
+ /* Also eliminate duplicate boolist entries */
+
+ TAILQ_FOREACH(mod, &module_bootlist, mod_chain) {
+ if (strcmp(mod->mod_info->mi_name, name) == 0) {
+ module_error("duplicate bootlist entry for module "
+ "`%s'", name);
+ return EEXIST;
+ }
+ }
+
+ mod = module_newmodule(MODULE_SOURCE_BOOT);
+ if (mod == NULL) {
+ return ENOMEM;
+ }
+
error = kobj_load_mem(&mod->mod_kobj, name, base, size);
if (error != 0) {
kmem_free(mod, sizeof(*mod));
Home |
Main Index |
Thread Index |
Old Index