@@ -499,12 +499,12 @@ efi_status_t efi_load_initrd_dev_path(struct linux_efi_initrd *initrd,
unsigned long max)
{
efi_guid_t lf2_proto_guid = EFI_LOAD_FILE2_PROTOCOL_GUID;
- efi_device_path_protocol_t *dp;
+ const efi_device_path_protocol_t *dp;
efi_load_file2_protocol_t *lf2;
efi_handle_t handle;
efi_status_t status;
- dp = (efi_device_path_protocol_t *)&initrd_dev_path;
+ dp = &initrd_dev_path.vendor.header;
status = efi_bs_call(locate_device_path, &lf2_proto_guid, &dp, &handle);
if (status != EFI_SUCCESS)
return status;
@@ -285,7 +285,7 @@ union efi_boot_services {
void *, unsigned long *,
efi_handle_t *);
efi_status_t (__efiapi *locate_device_path)(efi_guid_t *,
- efi_device_path_protocol_t **,
+ const efi_device_path_protocol_t **,
efi_handle_t *);
efi_status_t (__efiapi *install_configuration_table)(efi_guid_t *,
void *);
@@ -894,7 +894,7 @@ typedef union efi_load_file_protocol efi_load_file2_protocol_t;
union efi_load_file_protocol {
struct {
efi_status_t (__efiapi *load_file)(efi_load_file_protocol_t *,
- efi_device_path_protocol_t *,
+ const efi_device_path_protocol_t *,
bool, unsigned long *, void *);
};
struct {
@@ -131,7 +131,7 @@ static efi_status_t efi_open_device_path(efi_file_protocol_t **volume,
efi_guid_t text_to_dp_guid = EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL_GUID;
static efi_device_path_from_text_protocol_t *text_to_dp = NULL;
efi_guid_t fs_proto = EFI_FILE_SYSTEM_GUID;
- efi_device_path_protocol_t *initrd_dp;
+ const efi_device_path_protocol_t *initrd_dp;
efi_simple_file_system_protocol_t *io;
struct efi_file_path_dev_path *fpath;
efi_handle_t handle;
The EFI APIs that deal with device path protocol instances never modify them, but given that these APIs do not use const qualified pointers at all, but instead uses IN and OUT modifiers that are #define'd to empty tokens, we cannot currently pass a device path protocol pointer that refers to a read-only object. So add the const qualification where appropriate, and drop a cast that is no longer necessary. Signed-off-by: Ard Biesheuvel <ardb@kernel.org> --- drivers/firmware/efi/libstub/efi-stub-helper.c | 4 ++-- drivers/firmware/efi/libstub/efistub.h | 4 ++-- drivers/firmware/efi/libstub/file.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-)