loader/i386/pc/linux: Fix resource leak
PATCH 1/1 loader/i386/pc/linux: Fix resource leak
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().
--- grub-core/loader/i386/pc/linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
grub-core/loader/i386/pc/linux.c +1 -1
@@ -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); }
Signature · 7 lines
2.43.5 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 8 lines · Lidong Chen via Grub-devel
In
grub_cmd_initrd(), memory is allocated for variableinitrd_ctxbefore callinggrub_relocator_alloc_chunk_align_safe(). When the function call fails,initrd_ctxshould be freed before exitinggrub_cmd_initrd().Fixes CID 473852Signed-off-by Lidong Chen <[email protected]>
it looks good..
Quoted 18 lines
--- grub-core/loader/i386/pc/linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)grub-core/loader/i386/pc/linux.c +1
-1@@ -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);
Quoted 1 line
}
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Daniel Kiper via Grub-devel
Reviewed-by Daniel KiperQuoted 6 lines · sudhakar
Quoted 5 lines · Lidong Chen via Grub-devel
In
grub_cmd_initrd(), memory is allocated for variableinitrd_ctxbefore callinggrub_relocator_alloc_chunk_align_safe(). When the function call fails,initrd_ctxshould be freed before exitinggrub_cmd_initrd().
Quoted 7 lines
Quoted 3 lines
Fixes CID 473852Signed-off-by Lidong Chen <[email protected]>it looks good..
Reviewed-by Sudhakar Kuppusamy <[email protected]>
Daniel
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel