[PATCH v2 1/3] efi/libstub: Use const qualified device path protocol pointers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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(-)

diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c
index 1e0203d74691ffcc..ff60e3a78337ce5c 100644
--- a/drivers/firmware/efi/libstub/efi-stub-helper.c
+++ b/drivers/firmware/efi/libstub/efi-stub-helper.c
@@ -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;
diff --git a/drivers/firmware/efi/libstub/efistub.h b/drivers/firmware/efi/libstub/efistub.h
index 6bd3bb86d9679a1c..96a04ee05cdbb8bf 100644
--- a/drivers/firmware/efi/libstub/efistub.h
+++ b/drivers/firmware/efi/libstub/efistub.h
@@ -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 {
diff --git a/drivers/firmware/efi/libstub/file.c b/drivers/firmware/efi/libstub/file.c
index d6a025df07dcf9ef..207dc578db910336 100644
--- a/drivers/firmware/efi/libstub/file.c
+++ b/drivers/firmware/efi/libstub/file.c
@@ -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;
-- 
2.39.2




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux