mirror of
https://github.com/ipxe/ipxe.git
synced 2026-05-04 20:06:30 +02:00
[efi] Allow creating an image device handle with no parent device
When we fall back to using our own loaded image's device handle (instead of the most recently opened SNP device handle), we may find that the device handle is no longer valid since we have disconnected the driver that originally provided it. Check for existence of the device path protocol on the identified parent handle, and choose not to attempt to set a parent-child relationship if the parent handle appears to no longer be valid. Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
parent
5a17d8daf3
commit
cbeda2012a
@ -230,8 +230,11 @@ static int efi_image_exec ( struct image *image ) {
|
||||
parent = efi_loaded_image->DeviceHandle;
|
||||
basepath = efi_loaded_image_path;
|
||||
netdev = NULL;
|
||||
DBGC ( image, "EFIIMAGE %s using %s\n",
|
||||
image->name, efi_devpath_text ( basepath ) );
|
||||
if ( efi_test ( parent, &efi_device_path_protocol_guid ) != 0 )
|
||||
parent = NULL;
|
||||
DBGC ( image, "EFIIMAGE %s using %s%s\n",
|
||||
image->name, efi_devpath_text ( basepath ),
|
||||
( parent ? "" : " (removed)" ) );
|
||||
}
|
||||
|
||||
/* Construct URI device path */
|
||||
@ -259,7 +262,8 @@ static int efi_image_exec ( struct image *image ) {
|
||||
image->name, efi_handle_name ( device ) );
|
||||
|
||||
/* Add as a child of the parent device */
|
||||
if ( ( rc = efi_child_add ( parent, device ) ) != 0 ) {
|
||||
if ( ( parent != NULL ) &&
|
||||
( rc = efi_child_add ( parent, device ) ) != 0 ) {
|
||||
DBGC ( image, "EFIIMAGE %s could not become child of %s: %s\n",
|
||||
image->name, efi_handle_name ( parent ),
|
||||
strerror ( rc ) );
|
||||
@ -454,7 +458,8 @@ static int efi_image_exec ( struct image *image ) {
|
||||
unregister_image ( image );
|
||||
err_register_image:
|
||||
image->flags ^= toggle;
|
||||
efi_child_del ( parent, device );
|
||||
if ( parent )
|
||||
efi_child_del ( parent, device );
|
||||
err_child_add:
|
||||
bs->UninstallMultipleProtocolInterfaces (
|
||||
device,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user