mirror of
https://github.com/ventoy/Ventoy.git
synced 2025-01-27 06:33:23 -05:00
Fix the chain load memory alloc failure in UEFI mode.
This commit is contained in:
parent
61f289aa8a
commit
0f3d48b3d9
@ -38,6 +38,7 @@
|
||||
#include <grub/memory.h>
|
||||
#ifdef GRUB_MACHINE_EFI
|
||||
#include <grub/efi/efi.h>
|
||||
#include <grub/efi/memory.h>
|
||||
#endif
|
||||
#include <grub/ventoy.h>
|
||||
#include "ventoy_def.h"
|
||||
@ -135,6 +136,22 @@ int ventoy_is_efi_os(void)
|
||||
return g_efi_os;
|
||||
}
|
||||
|
||||
void * ventoy_alloc_chain(grub_size_t size)
|
||||
{
|
||||
void *p = NULL;
|
||||
|
||||
p = grub_malloc(size);
|
||||
#ifdef GRUB_MACHINE_EFI
|
||||
if (!p)
|
||||
{
|
||||
p = grub_efi_allocate_any_pages(GRUB_EFI_BYTES_TO_PAGES(size));
|
||||
}
|
||||
#endif
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
static int ventoy_arch_mode_init(void)
|
||||
{
|
||||
#ifdef GRUB_MACHINE_EFI
|
||||
|
@ -1206,6 +1206,7 @@ grub_err_t ventoy_cmd_browser_dir(grub_extcmd_context_t ctxt, int argc, char **a
|
||||
grub_err_t ventoy_cmd_browser_disk(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
int ventoy_get_fs_type(const char *fs);
|
||||
int ventoy_img_name_valid(const char *filename, grub_size_t namelen);
|
||||
void * ventoy_alloc_chain(grub_size_t size);
|
||||
|
||||
#endif /* __VENTOY_DEF_H__ */
|
||||
|
||||
|
@ -1623,10 +1623,10 @@ grub_err_t ventoy_cmd_linux_chain_data(grub_extcmd_context_t ctxt, int argc, cha
|
||||
}
|
||||
}
|
||||
|
||||
chain = grub_malloc(size);
|
||||
chain = ventoy_alloc_chain(size);
|
||||
if (!chain)
|
||||
{
|
||||
grub_printf("Failed to alloc chain memory size %u\n", size);
|
||||
grub_printf("Failed to alloc chain linux memory size %u\n", size);
|
||||
grub_file_close(file);
|
||||
return 1;
|
||||
}
|
||||
|
@ -1185,10 +1185,10 @@ grub_err_t ventoy_cmd_unix_chain_data(grub_extcmd_context_t ctxt, int argc, char
|
||||
}
|
||||
}
|
||||
|
||||
chain = grub_malloc(size);
|
||||
chain = ventoy_alloc_chain(size);
|
||||
if (!chain)
|
||||
{
|
||||
grub_printf("Failed to alloc chain memory size %u\n", size);
|
||||
grub_printf("Failed to alloc chain unix memory size %u\n", size);
|
||||
grub_file_close(file);
|
||||
return 1;
|
||||
}
|
||||
|
@ -687,10 +687,10 @@ grub_err_t ventoy_cmd_raw_chain_data(grub_extcmd_context_t ctxt, int argc, char
|
||||
}
|
||||
}
|
||||
|
||||
chain = grub_malloc(size);
|
||||
chain = ventoy_alloc_chain(size);
|
||||
if (!chain)
|
||||
{
|
||||
grub_printf("Failed to alloc chain memory size %u\n", size);
|
||||
grub_printf("Failed to alloc chain raw memory size %u\n", size);
|
||||
grub_file_close(file);
|
||||
return 1;
|
||||
}
|
||||
|
@ -1896,10 +1896,10 @@ grub_err_t ventoy_cmd_windows_chain_data(grub_extcmd_context_t ctxt, int argc, c
|
||||
}
|
||||
}
|
||||
|
||||
chain = grub_malloc(size);
|
||||
chain = ventoy_alloc_chain(size);
|
||||
if (!chain)
|
||||
{
|
||||
grub_printf("Failed to alloc chain memory size %u\n", size);
|
||||
grub_printf("Failed to alloc chain win1 memory size %u\n", size);
|
||||
grub_file_close(file);
|
||||
return 1;
|
||||
}
|
||||
@ -2129,10 +2129,10 @@ static grub_err_t ventoy_vlnk_wim_chain_data(grub_file_t wimfile)
|
||||
}
|
||||
}
|
||||
|
||||
chain = grub_malloc(size);
|
||||
chain = ventoy_alloc_chain(size);
|
||||
if (!chain)
|
||||
{
|
||||
grub_printf("Failed to alloc chain memory size %u\n", size);
|
||||
grub_printf("Failed to alloc chain win2 memory size %u\n", size);
|
||||
grub_file_close(file);
|
||||
return 1;
|
||||
}
|
||||
@ -2294,10 +2294,10 @@ static grub_err_t ventoy_normal_wim_chain_data(grub_file_t wimfile)
|
||||
}
|
||||
}
|
||||
|
||||
chain = grub_malloc(size);
|
||||
chain = ventoy_alloc_chain(size);
|
||||
if (!chain)
|
||||
{
|
||||
grub_printf("Failed to alloc chain memory size %u\n", size);
|
||||
grub_printf("Failed to alloc chain win3 memory size %u\n", size);
|
||||
grub_file_close(file);
|
||||
return 1;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user