grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
From: Adriano Cordova <adrianox@gmail.com>
To: grub-devel@gnu.org
Cc: heinrich.schuchardt@canonical.com, mate.kukri@canonical.com,
	Adriano Cordova <adriano.cordova@canonical.com>
Subject: [PATCH] loader/efi/linux.c: unload previous linux before updating kernel size
Date: Wed, 18 Jun 2025 11:38:14 -0400	[thread overview]
Message-ID: <20250618153815.131867-1-adriano.cordova@canonical.com> (raw)

Unload previous linux before updating the global variable kernel_size,
otherwise the previous linux gets deallocated with the kernel_size of
the linux that is being currently loaded.

Signed-off-by: Adriano Cordova <adriano.cordova@canonical.com>
---
 grub-core/loader/efi/linux.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c
index 78ea07ca8..8ca06a373 100644
--- a/grub-core/loader/efi/linux.c
+++ b/grub-core/loader/efi/linux.c
@@ -489,6 +489,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
   if (!file)
     goto fail;
 
+  grub_loader_unset();
+
   kernel_size = grub_file_size (file);
 
   if (grub_arch_efi_linux_load_image_header (file, &lh) != GRUB_ERR_NONE)
@@ -511,8 +513,6 @@ fallback:
     }
 #endif
 
-  grub_loader_unset();
-
   grub_dprintf ("linux", "kernel file size: %lld\n", (long long) kernel_size);
   kernel_addr = grub_efi_allocate_any_pages (GRUB_EFI_BYTES_TO_PAGES (kernel_size));
   grub_dprintf ("linux", "kernel numpages: %lld\n",
-- 
2.48.1


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

             reply	other threads:[~2025-06-18 15:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-18 15:38 Adriano Cordova [this message]
2025-06-23 17:42 ` [PATCH] loader/efi/linux.c: unload previous linux before updating kernel size Daniel Kiper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250618153815.131867-1-adriano.cordova@canonical.com \
    --to=adrianox@gmail.com \
    --cc=adriano.cordova@canonical.com \
    --cc=grub-devel@gnu.org \
    --cc=heinrich.schuchardt@canonical.com \
    --cc=mate.kukri@canonical.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).