]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
loader/multiboot: Do not add modules before successful download
authorValentin Gehrke <valentin.gehrke@kernkonzept.com>
Wed, 30 Oct 2024 17:12:56 +0000 (18:12 +0100)
committerDaniel Kiper <daniel.kiper@oracle.com>
Thu, 31 Oct 2024 15:29:01 +0000 (16:29 +0100)
Multiboot modules that could not be read successfully, e.g. via network,
should not be added to the list of modules to forward to the operating
system that is to be booted subsequently.

This patch is necessary because even if a grub.cfg checks whether or not
a module was successfully downloaded, it is futile to retry a failed
download as the corrupted module will be forwarded either way.

Signed-off-by: Valentin Gehrke <valentin.gehrke@kernkonzept.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/loader/multiboot.c

index 94be512c4d0c917c1aa90b68bdb9e0279951bf03..36b27a906d1ba67a4417f532460226a7cfa3b98a 100644 (file)
@@ -420,13 +420,6 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)),
       target = 0;
     }
 
-  err = GRUB_MULTIBOOT (add_module) (target, size, argc - 1, argv + 1);
-  if (err)
-    {
-      grub_file_close (file);
-      return err;
-    }
-
   if (size && grub_file_read (file, module, size) != size)
     {
       grub_file_close (file);
@@ -437,7 +430,8 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)),
     }
 
   grub_file_close (file);
-  return GRUB_ERR_NONE;
+
+  return GRUB_MULTIBOOT (add_module) (target, size, argc - 1, argv + 1);
 }
 
 static grub_command_t cmd_multiboot, cmd_module;