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