Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern In case of error resolving symbol references, we ca...
details: https://anonhg.NetBSD.org/src/rev/e6858feb65a1
branches: trunk
changeset: 999815:e6858feb65a1
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Wed Jun 19 15:01:01 2019 +0000
description:
In case of error resolving symbol references, we cannot rely on the
module's name still being available - it may be destroyed when
kobj_affix() unloads the object. So make a copy of the name first
so we can use it in a useful error message.
(Without this, I've have affix errors go into an infinite loop
trying to print the error message!)
diffstat:
sys/kern/kern_module.c | 25 +++++++++++++++++--------
1 files changed, 17 insertions(+), 8 deletions(-)
diffs (46 lines):
diff -r 7947c32be79f -r e6858feb65a1 sys/kern/kern_module.c
--- a/sys/kern/kern_module.c Wed Jun 19 14:16:06 2019 +0000
+++ b/sys/kern/kern_module.c Wed Jun 19 15:01:01 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_module.c,v 1.135 2019/06/11 15:20:57 pgoyette Exp $ */
+/* $NetBSD: kern_module.c,v 1.136 2019/06/19 15:01:01 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.135 2019/06/11 15:20:57 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.136 2019/06/19 15:01:01 pgoyette Exp $");
#define _MODULE_INTERNAL
@@ -1214,12 +1214,21 @@
* We loaded all needed modules successfully: perform global
* relocations and initialize.
*/
- error = kobj_affix(mod->mod_kobj, mi->mi_name);
- if (error != 0) {
- /* Cannot touch 'mi' as the module is now gone. */
- module_error("unable to affix module `%s', error %d", name,
- error);
- goto fail2;
+ {
+ char xname[MAXMODNAME];
+
+ /*
+ * In case of error the entire module is gone, so we
+ * need to save its name for possible error report.
+ */
+
+ strlcpy(xname, mi->mi_name, MAXMODNAME);
+ error = kobj_affix(mod->mod_kobj, mi->mi_name);
+ if (error != 0) {
+ module_error("unable to affix module `%s', error %d",
+ xname, error);
+ goto fail2;
+ }
}
if (filedict) {
Home |
Main Index |
Thread Index |
Old Index