From: Lidong Chen via Grub-devel <grub-devel@gnu.org>
To: grub-devel@gnu.org, daniel.kiper@oracle.com
Cc: Lidong Chen <lidong.chen@oracle.com>
Subject: [PATCH] loader/i386/pc/linux: Fix resource leak
Date: Mon, 23 Jun 2025 17:46:01 +0000 [thread overview]
Message-ID: <20250623174601.1082626-1-lidong.chen@oracle.com> (raw)
In grub_cmd_initrd(), memory is allocated for variable initrd_ctx
before calling grub_relocator_alloc_chunk_align_safe(). When the
function call fails, initrd_ctx should be freed before exiting
grub_cmd_initrd().
Fixes: CID 473852
Signed-off-by: Lidong Chen <lidong.chen@oracle.com>
---
grub-core/loader/i386/pc/linux.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c
index 4adeee9ae..0c2a4ae51 100644
--- a/grub-core/loader/i386/pc/linux.c
+++ b/grub-core/loader/i386/pc/linux.c
@@ -457,7 +457,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
err = grub_relocator_alloc_chunk_align_safe (relocator, &ch, addr_min, addr_max, size,
0x1000, GRUB_RELOCATOR_PREFERENCE_HIGH, 0);
if (err)
- return err;
+ goto fail;
initrd_chunk = get_virtual_current_address (ch);
initrd_addr = get_physical_target_address (ch);
}
--
2.43.5
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
next reply other threads:[~2025-06-23 17:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-23 17:46 Lidong Chen via Grub-devel [this message]
2025-06-23 18:57 ` [PATCH] loader/i386/pc/linux: Fix resource leak sudhakar
2025-06-26 18:00 ` Daniel Kiper via Grub-devel
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=20250623174601.1082626-1-lidong.chen@oracle.com \
--to=grub-devel@gnu.org \
--cc=daniel.kiper@oracle.com \
--cc=lidong.chen@oracle.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).