]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
bsd: Ensure that kernel is loaded before loading module.
authorVladimir Serbinenko <phcoder@gmail.com>
Fri, 26 Feb 2016 13:56:22 +0000 (14:56 +0100)
committerVladimir Serbinenko <phcoder@gmail.com>
Sat, 27 Feb 2016 12:35:36 +0000 (13:35 +0100)
kernel_type may be set to the type of failed kernel. This patching-up is
easier than to reflow kernel loading routines.

grub-core/loader/i386/bsd.c

index bc377b362698ce7889bb13c2c524d686d022b832..7f96515da6523c1fefb42d673fd44ca88523fbd8 100644 (file)
@@ -1889,6 +1889,10 @@ grub_cmd_freebsd_module (grub_command_t cmd __attribute__ ((unused)),
   grub_err_t err;
   void *src;
 
+  if (! grub_loader_is_loaded ())
+    return grub_error (GRUB_ERR_BAD_ARGUMENT,
+                      N_("you need to load the kernel first"));
+
   if (kernel_type != KERNEL_TYPE_FREEBSD)
     return grub_error (GRUB_ERR_BAD_ARGUMENT, "no FreeBSD loaded");
 
@@ -1992,6 +1996,10 @@ grub_cmd_netbsd_module (grub_command_t cmd,
 {
   grub_uint32_t type;
 
+  if (! grub_loader_is_loaded ())
+    return grub_error (GRUB_ERR_BAD_ARGUMENT,
+                      N_("you need to load the kernel first"));
+
   if (kernel_type != KERNEL_TYPE_NETBSD)
     return grub_error (GRUB_ERR_BAD_ARGUMENT, "no NetBSD loaded");
 
@@ -2070,6 +2078,10 @@ grub_cmd_openbsd_ramdisk (grub_command_t cmd __attribute__ ((unused)),
   if (argc != 1)
     return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
 
+  if (! grub_loader_is_loaded ())
+    return grub_error (GRUB_ERR_BAD_ARGUMENT,
+                      N_("you need to load the kernel first"));
+
   if (kernel_type != KERNEL_TYPE_OPENBSD)
     return grub_error (GRUB_ERR_BAD_OS, "no kOpenBSD loaded");