From c2942f0904edffa58877abf9d1f13c5d91a0ddee Mon Sep 17 00:00:00 2001
From: Glenn L McGrath <bug1@ihug.co.nz>
Date: Sun, 31 Aug 2003 01:58:18 +0000
Subject: "insmod caches the symbolname in a variable before modifying it and
 uses the cached value afterwards." - Jean Wolter

---
 modutils/insmod.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/modutils/insmod.c b/modutils/insmod.c
index 4676b5aa8..54463a9d0 100644
--- a/modutils/insmod.c
+++ b/modutils/insmod.c
@@ -253,7 +253,7 @@
 #ifndef MODUTILS_MODULE_H
 static const int MODUTILS_MODULE_H = 1;
 
-#ident "$Id: insmod.c,v 1.101 2003/08/30 06:00:33 bug1 Exp $"
+#ident "$Id: insmod.c,v 1.102 2003/08/31 01:58:18 bug1 Exp $"
 
 /* This file contains the structures used by the 2.0 and 2.1 kernels.
    We do not use the kernel headers directly because we do not wish
@@ -474,7 +474,7 @@ int delete_module(const char *);
 #ifndef MODUTILS_OBJ_H
 static const int MODUTILS_OBJ_H = 1;
 
-#ident "$Id: insmod.c,v 1.101 2003/08/30 06:00:33 bug1 Exp $"
+#ident "$Id: insmod.c,v 1.102 2003/08/31 01:58:18 bug1 Exp $"
 
 /* The relocatable object is manipulated using elfin types.  */
 
@@ -1942,7 +1942,7 @@ add_symbols_from(
 		   argument initialization.  We will also create a false
 		   dependency on the module.  */
 		struct obj_symbol *sym;
-		char *name = (char *)s->name;
+		char *name;
 
 		/* GPL licensed modules can use symbols exported with
 		 * EXPORT_SYMBOL_GPL, so ignore any GPLONLY_ prefix on the
@@ -1956,6 +1956,7 @@ add_symbols_from(
 			else
 				continue;
 		}
+		name = (char *)s->name;
 
 #ifdef SYMBOL_PREFIX
 		/* Prepend SYMBOL_PREFIX to the symbol's name (the
@@ -4129,6 +4130,14 @@ extern int insmod_main( int argc, char **argv)
 
 	printf("Using %s\n", m_filename);
 
+#ifdef CONFIG_FEATURE_REALLY_NEW_MODULE_INTERFACE
+    if (create_module(NULL, 0) < 0 && errno == ENOSYS) {
+		optind--;
+		argv[optind] = m_filename;
+		return insmod_ng_main(argc - optind, argv + optind);
+    }
+#endif
+
 	if ((f = obj_load(fp, LOADBITS)) == NULL)
 		bb_perror_msg_and_die("Could not load the module");
 
-- 
cgit v1.2.3-55-g6feb