mirror of
https://github.com/ipxe/ipxe
synced 2026-04-16 03:00:10 +03:00
[efi] Create a copy of the system flattened device tree, if present
EFI configuration tables may be freed at any time, and there is no way to be notified when the table becomes invalidated. Create a copy of the system flattened device tree (if present), so that we do not risk being left with an invalid pointer. Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -44,6 +44,8 @@ EFI_USE_TABLE ( FDT_TABLE, &efi_fdt, 0 );
|
||||
*
|
||||
*/
|
||||
static void efi_fdt_init ( void ) {
|
||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||
EFI_STATUS efirc;
|
||||
int rc;
|
||||
|
||||
/* Do nothing if no configuration table is present */
|
||||
@@ -59,6 +61,15 @@ static void efi_fdt_init ( void ) {
|
||||
strerror ( rc ) );
|
||||
return;
|
||||
}
|
||||
|
||||
/* Create copy, since table may be removed at any time */
|
||||
if ( ( efirc = bs->AllocatePool ( EfiBootServicesData, sysfdt.len,
|
||||
&sysfdt.raw ) ) != 0 ) {
|
||||
DBGC ( &efi_fdt, "EFIFDT could not create copy\n" );
|
||||
sysfdt.len = 0;
|
||||
return;
|
||||
}
|
||||
memcpy ( sysfdt.raw, efi_fdt, sysfdt.len );
|
||||
}
|
||||
|
||||
/** EFI Flattened Device Tree initialisation function */
|
||||
|
||||
Reference in New Issue
Block a user