grub_dl_get() can return non-NULL for an already loaded module. insmod should not increase it refcount. Only increase refcount if the module is newly loaded or if the module is unused and autoloaded, so that it won't get unloaded automatically.
It's not perfect, but close enough. insmod won't lock autoloaded modules with dependencies. But it can be fixed by running insmod on the dependent module. ChangeLog: * kern/corecmd.c (grub_core_cmd_insmod): Exit without increasing refcount if the module is already loaded. --- kern/corecmd.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/kern/corecmd.c b/kern/corecmd.c index 03944f2..078b33e 100644 --- a/kern/corecmd.c +++ b/kern/corecmd.c @@ -102,7 +102,8 @@ grub_core_cmd_insmod (struct grub_command *cmd __attribute__ ((unused)), else mod = grub_dl_load_file (argv[0]); - if (mod) + /* Pin module in memory unless already pinned */ + if (mod && mod->ref_count == 0) grub_dl_ref (mod); return 0; _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel