|
|
c4e390 |
From 0f008fb687338498ee7d84980a7aca6aa4dec919 Mon Sep 17 00:00:00 2001
|
|
|
c4e390 |
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
|
|
|
c4e390 |
Date: Fri, 26 Jun 2020 10:51:43 -0400
|
|
|
c4e390 |
Subject: [PATCH 311/336] multiboot2: Fix memory leak if
|
|
|
c4e390 |
grub_create_loader_cmdline() fails
|
|
|
c4e390 |
|
|
|
c4e390 |
Fixes: CID 292468
|
|
|
c4e390 |
|
|
|
c4e390 |
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
|
|
|
c4e390 |
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
|
|
c4e390 |
Upstream-commit-id: cd6760b6289
|
|
|
c4e390 |
---
|
|
|
c4e390 |
grub-core/loader/multiboot_mbi2.c | 11 +++++++++--
|
|
|
c4e390 |
1 file changed, 9 insertions(+), 2 deletions(-)
|
|
|
c4e390 |
|
|
|
c4e390 |
diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c
|
|
|
c4e390 |
index 83e8919fa9a..7e01dfb5ee7 100644
|
|
|
c4e390 |
--- a/grub-core/loader/multiboot_mbi2.c
|
|
|
c4e390 |
+++ b/grub-core/loader/multiboot_mbi2.c
|
|
|
c4e390 |
@@ -957,6 +957,7 @@ grub_multiboot_add_module (grub_addr_t start, grub_size_t size,
|
|
|
c4e390 |
{
|
|
|
c4e390 |
struct module *newmod;
|
|
|
c4e390 |
grub_size_t len = 0;
|
|
|
c4e390 |
+ grub_err_t err;
|
|
|
c4e390 |
|
|
|
c4e390 |
newmod = grub_malloc (sizeof (*newmod));
|
|
|
c4e390 |
if (!newmod)
|
|
|
c4e390 |
@@ -975,8 +976,14 @@ grub_multiboot_add_module (grub_addr_t start, grub_size_t size,
|
|
|
c4e390 |
newmod->cmdline_size = len;
|
|
|
c4e390 |
total_modcmd += ALIGN_UP (len, MULTIBOOT_TAG_ALIGN);
|
|
|
c4e390 |
|
|
|
c4e390 |
- grub_create_loader_cmdline (argc, argv, newmod->cmdline,
|
|
|
c4e390 |
- newmod->cmdline_size);
|
|
|
c4e390 |
+ err = grub_create_loader_cmdline (argc, argv, newmod->cmdline,
|
|
|
c4e390 |
+ newmod->cmdline_size);
|
|
|
c4e390 |
+ if (err)
|
|
|
c4e390 |
+ {
|
|
|
c4e390 |
+ grub_free (newmod->cmdline);
|
|
|
c4e390 |
+ grub_free (newmod);
|
|
|
c4e390 |
+ return err;
|
|
|
c4e390 |
+ }
|
|
|
c4e390 |
|
|
|
c4e390 |
if (modules_last)
|
|
|
c4e390 |
modules_last->next = newmod;
|
|
|
c4e390 |
--
|
|
|
c4e390 |
2.26.2
|
|
|
c4e390 |
|