2021-03-02 18:56:20 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2020-07-29 17:15:26 +00:00
|
|
|
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
|
|
|
|
Date: Fri, 26 Jun 2020 10:51:43 -0400
|
2021-03-02 18:56:20 +00:00
|
|
|
Subject: [PATCH] multiboot2: Fix memory leak if grub_create_loader_cmdline()
|
|
|
|
fails
|
2020-07-29 17:15:26 +00:00
|
|
|
|
|
|
|
Fixes: CID 292468
|
|
|
|
|
|
|
|
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
|
|
|
|
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
|
|
|
Upstream-commit-id: cd6760b6289
|
|
|
|
---
|
|
|
|
grub-core/loader/multiboot_mbi2.c | 11 +++++++++--
|
|
|
|
1 file changed, 9 insertions(+), 2 deletions(-)
|
|
|
|
|
|
|
|
diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c
|
2022-05-10 07:20:45 +00:00
|
|
|
index 54078455e..872dcd42e 100644
|
2020-07-29 17:15:26 +00:00
|
|
|
--- a/grub-core/loader/multiboot_mbi2.c
|
|
|
|
+++ b/grub-core/loader/multiboot_mbi2.c
|
|
|
|
@@ -1089,6 +1089,7 @@ grub_multiboot2_add_module (grub_addr_t start, grub_size_t size,
|
|
|
|
{
|
|
|
|
struct module *newmod;
|
|
|
|
grub_size_t len = 0;
|
|
|
|
+ grub_err_t err = 0;
|
|
|
|
|
|
|
|
newmod = grub_malloc (sizeof (*newmod));
|
|
|
|
if (!newmod)
|
|
|
|
@@ -1107,8 +1108,14 @@ grub_multiboot2_add_module (grub_addr_t start, grub_size_t size,
|
|
|
|
newmod->cmdline_size = len;
|
|
|
|
total_modcmd += ALIGN_UP (len, MULTIBOOT_TAG_ALIGN);
|
|
|
|
|
|
|
|
- grub_create_loader_cmdline (argc, argv, newmod->cmdline,
|
|
|
|
- newmod->cmdline_size);
|
|
|
|
+ err = grub_create_loader_cmdline (argc, argv, newmod->cmdline,
|
|
|
|
+ newmod->cmdline_size);
|
|
|
|
+ if (err)
|
|
|
|
+ {
|
|
|
|
+ grub_free (newmod->cmdline);
|
|
|
|
+ grub_free (newmod);
|
|
|
|
+ return err;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
if (modules_last)
|
|
|
|
modules_last->next = newmod;
|