Skip to contentSkip to conversation

mii module broken under new scheme

PATCH Rusty Russell 1 participant 1 message Nov 20, 2002

lore
Share & tools
lore
#0 lore raw

Linus, this is a better fix, until the module post-link patch goes in (rth and I are working on it, Kai likes the idea for other reasons).

Once again, fix up my assumptions so we err on the side of not breaking anything.

Untested (on plane home and low on battery), but trivial.

Hope this helps,
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

kernel/module.c +11 -8
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal linux-2.5-bk/kernel/module.c working-2.5-bk-modname/kernel/module.c
@@ -895,12 +895,6 @@ static struct module *load_module(void *
 #endif
 	}
 
-	if (!modnameindex) {
-		DEBUGP("Module has no name!\n");
-		err = -ENOEXEC;
-		goto free_hdr;
-	}
-
 	/* Now allocate space for the module proper, and copy name and args. */
 	err = strlen_user(uargs);
 	if (err < 0)
@@ -917,8 +911,17 @@ static struct module *load_module(void *
 		err = -EFAULT;
 		goto free_mod;
 	}
-	strncpy(mod->name, (char *)hdr + sechdrs[modnameindex].sh_offset,
-		sizeof(mod->name)-1);
+
+	if (modnameindex)
+		strncpy(mod->name,
+			(char *)hdr + sechdrs[modnameindex].sh_offset,
+			sizeof(mod->name)-1);
+	else {
+		/* FIXME: With module post-link phase, always insert
+                   .modname section. --RR */
+		static unsigned int num_unknown;
+		sprintf(mod->name, "unknown%u", num_unknown++);
+	}
 
 	if (find_module(mod->name)) {
 		err = -EEXIST;