]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
loader/i386/pc/linux: Fix resource leak
authorLidong Chen <lidong.chen@oracle.com>
Mon, 23 Jun 2025 17:46:01 +0000 (17:46 +0000)
committerDaniel Kiper <daniel.kiper@oracle.com>
Thu, 26 Jun 2025 18:02:05 +0000 (20:02 +0200)
In grub_cmd_initrd(), memory is allocated for variable initrd_ctx
before calling grub_relocator_alloc_chunk_align_safe(). When the
function call fails, initrd_ctx should be freed before exiting
grub_cmd_initrd().

Fixes: CID 473852
Signed-off-by: Lidong Chen <lidong.chen@oracle.com>
Reviewed-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/loader/i386/pc/linux.c

index 4adeee9ae0011a5f76d33caa63e7f9bc0e7b098a..0c2a4ae51222cab69c35daf8990492be4e9b5702 100644 (file)
@@ -457,7 +457,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
     err = grub_relocator_alloc_chunk_align_safe (relocator, &ch, addr_min, addr_max, size,
                                                 0x1000, GRUB_RELOCATOR_PREFERENCE_HIGH, 0);
     if (err)
-      return err;
+      goto fail;
     initrd_chunk = get_virtual_current_address (ch);
     initrd_addr = get_physical_target_address (ch);
   }