kmodloader: use the name of the module struct when unloading modules
authorJo-Philipp Wich <jow@openwrt.org>
Sat, 28 Sep 2013 16:25:47 +0000 (16:25 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Sat, 28 Sep 2013 16:25:47 +0000 (16:25 +0000)
The module .ko file might be called differently than the name used
by the kernel internally, e.g. "nls_iso8859-1.ko" is called
"nls_iso8859_1" in lsmmod. The module removal syscall expects the
latter as well.

After this change, "rmmod" supports unloading the module even if the
user gives the file name spelling instead of the kernel internal one,
so that e.g. "rmmod nls_iso8859-1.ko" and "rmmod nls_iso8859_1" will
both succeed.

kmodloader.c

index dee4b7c..417d121 100644 (file)
@@ -553,13 +553,13 @@ static int main_rmmod(int argc, char **argv)
                LOG("module is not loaded\n");
                return -1;
        }
-       free_modules();
-
-       ret = syscall(__NR_delete_module, name, 0);
+       ret = syscall(__NR_delete_module, m->name, 0);
 
        if (ret)
                LOG("unloading the module failed\n");
 
+       free_modules();
+
        return ret;
 }