LocateDevicePath() advances the device path pointer, making it invalid
when freed.
if (!dev_path)
return EFI_OUT_OF_RESOURCES;
- status = BS->LocateDevicePath(&FileSystemProtocol, &dev_path, &h);
+ EFI_DEVICE_PATH *dp = dev_path;
+ status = BS->LocateDevicePath(&FileSystemProtocol, &dp, &h);
if (EFI_ERROR(status))
return status;
/* No need to check return value, this already happened in efi_main() */
root = LibOpenRoot(h);
- dev_path_str = DevicePathToStr(dev_path);
+ dev_path_str = DevicePathToStr(dp);
if (!dev_path_str)
return EFI_OUT_OF_RESOURCES;
hd->SignatureType = SIGNATURE_TYPE_GUID;
}
- err = BS->LocateDevicePath(&BlockIoProtocol, &partition_path, &new_device);
+ EFI_DEVICE_PATH *dp = partition_path;
+ err = BS->LocateDevicePath(&BlockIoProtocol, &dp, &new_device);
if (EFI_ERROR(err))
return err;