|
|
9723a8 |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
9723a8 |
From: Darren Kenny <darren.kenny@oracle.com>
|
|
|
9723a8 |
Date: Tue, 8 Dec 2020 10:00:51 +0000
|
|
|
9723a8 |
Subject: [PATCH] disk/ldm: Fix memory leak on uninserted lv references
|
|
|
9723a8 |
|
|
|
9723a8 |
The problem here is that the memory allocated to the variable lv is not
|
|
|
9723a8 |
yet inserted into the list that is being processed at the label fail2.
|
|
|
9723a8 |
|
|
|
9723a8 |
As we can already see at line 342, which correctly frees lv before going
|
|
|
9723a8 |
to fail2, we should also be doing that at these earlier jumps to fail2.
|
|
|
9723a8 |
|
|
|
9723a8 |
Fixes: CID 73824
|
|
|
9723a8 |
|
|
|
9723a8 |
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
|
|
|
9723a8 |
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
|
|
9723a8 |
---
|
|
|
9723a8 |
grub-core/disk/ldm.c | 10 ++++++++--
|
|
|
9723a8 |
1 file changed, 8 insertions(+), 2 deletions(-)
|
|
|
9723a8 |
|
|
|
9723a8 |
diff --git a/grub-core/disk/ldm.c b/grub-core/disk/ldm.c
|
|
|
b71686 |
index 54713f45a..e82e9899f 100644
|
|
|
9723a8 |
--- a/grub-core/disk/ldm.c
|
|
|
9723a8 |
+++ b/grub-core/disk/ldm.c
|
|
|
9723a8 |
@@ -321,7 +321,10 @@ make_vg (grub_disk_t disk,
|
|
|
9723a8 |
lv->visible = 1;
|
|
|
9723a8 |
lv->segments = grub_zalloc (sizeof (*lv->segments));
|
|
|
9723a8 |
if (!lv->segments)
|
|
|
9723a8 |
- goto fail2;
|
|
|
9723a8 |
+ {
|
|
|
9723a8 |
+ grub_free (lv);
|
|
|
9723a8 |
+ goto fail2;
|
|
|
9723a8 |
+ }
|
|
|
9723a8 |
lv->segments->start_extent = 0;
|
|
|
9723a8 |
lv->segments->type = GRUB_DISKFILTER_MIRROR;
|
|
|
9723a8 |
lv->segments->node_count = 0;
|
|
|
9723a8 |
@@ -329,7 +332,10 @@ make_vg (grub_disk_t disk,
|
|
|
9723a8 |
lv->segments->nodes = grub_calloc (lv->segments->node_alloc,
|
|
|
9723a8 |
sizeof (*lv->segments->nodes));
|
|
|
9723a8 |
if (!lv->segments->nodes)
|
|
|
9723a8 |
- goto fail2;
|
|
|
9723a8 |
+ {
|
|
|
9723a8 |
+ grub_free (lv);
|
|
|
9723a8 |
+ goto fail2;
|
|
|
9723a8 |
+ }
|
|
|
9723a8 |
ptr = vblk[i].dynamic;
|
|
|
9723a8 |
if (ptr + *ptr + 1 >= vblk[i].dynamic
|
|
|
9723a8 |
+ sizeof (vblk[i].dynamic))
|