Commit 23e39f50ca7a (disk/ldm: Make sure comp data is freed before exiting from
make_vg()) fixed several spots in make_vg() where comp data was leaking memory
when an error was being handled but missed one. To avoid leaking memory, comp
should be freed when an error is being handled after comp has been successfully
allocated memory in the for loop.

Fixes: 23e39f50ca7a (disk/ldm: Make sure comp data is freed before exiting from 
make_vg())
Fixes: CID 73804

Signed-off-by: Alec Brown <alec.r.br...@oracle.com>
---
 grub-core/disk/ldm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/grub-core/disk/ldm.c b/grub-core/disk/ldm.c
index 4577a51dc..337abf704 100644
--- a/grub-core/disk/ldm.c
+++ b/grub-core/disk/ldm.c
@@ -487,6 +487,7 @@ make_vg (grub_disk_t disk,
          ptr = vblk[i].dynamic;
          if (ptr + *ptr + 1 >= vblk[i].dynamic + sizeof (vblk[i].dynamic))
            {
+             grub_free (comp);
              goto fail2;
            }
          comp->internal_id = grub_malloc ((grub_size_t) ptr[0] + 2);
-- 
2.27.0


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to