[efi] Use device path to locate filesystem from which we were loaded coverity_scan issue123 master github/coverity_scan github/issue123 github/master
authorMichael Brown <mcb30@ipxe.org>
Mon, 3 Aug 2020 14:26:25 +0000 (15:26 +0100)
committerMichael Brown <mcb30@ipxe.org>
Mon, 3 Aug 2020 14:41:30 +0000 (15:41 +0100)
commitc63e61df75c815da1dc93196bbb6a931743b736f
tree94ed0f9cf3d127dd1c1c0ca6bed5b539031996a4
parentfd47fa8fe1a3542621d5c97af349b3ae38146585
[efi] Use device path to locate filesystem from which we were loaded

The file:/ URI syntax may be used to refer to local files on the
filesystem from which the iPXE binary was loaded.  This is currently
implemented by directly using the DeviceHandle recorded in our
EFI_LOADED_IMAGE_PROTOCOL.

This mechanism will fail when a USB-enabled build of iPXE is loaded
from USB storage and subsequently installs its own USB host controller
drivers, since doing so will disconnect and reconnect the existing USB
storage drivers and thereby invalidate the original storage device
handle.

Fix by recording the device path for the loaded image's DeviceHandle
at initialisation time and later using the recorded device path to
locate the appropriate device handle.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/interface/efi/efi_init.c
src/interface/efi/efi_local.c