mirror of
https://src.fedoraproject.org/rpms/grub2.git
synced 2024-11-28 15:46:53 +00:00
48 lines
1.5 KiB
Diff
48 lines
1.5 KiB
Diff
|
From 3dff974017867a65e6aae14e14a0233ce9520cb3 Mon Sep 17 00:00:00 2001
|
||
|
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
|
||
|
Date: Fri, 26 Jun 2020 10:51:43 -0400
|
||
|
Subject: [PATCH 217/237] multiboot2: Fix memory leak if
|
||
|
grub_create_loader_cmdline() fails
|
||
|
|
||
|
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
|
||
|
index 54078455e2f..47d4c6f0977 100644
|
||
|
--- 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;
|
||
|
|
||
|
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;
|
||
|
--
|
||
|
2.26.2
|
||
|
|