aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2022-12-22 13:28:06 +0000
committerMichael Brown <mcb30@ipxe.org>2022-12-22 13:30:02 +0000
commit0f3ace92c6f7bd60a6688c0bacfa5aeacfdb5b73 (patch)
treea46994764981346594cd01d8347761327fc5a847
parentd879c8e4d9f3b00c09a7d199a2681705fc5b55d0 (diff)
downloadipxe-0f3ace92c6f7bd60a6688c0bacfa5aeacfdb5b73.zip
ipxe-0f3ace92c6f7bd60a6688c0bacfa5aeacfdb5b73.tar.gz
ipxe-0f3ace92c6f7bd60a6688c0bacfa5aeacfdb5b73.tar.bz2
[efi] Allow passing a NULL device path to path utility functions
Signed-off-by: Michael Brown <mcb30@ipxe.org>
-rw-r--r--src/interface/efi/efi_local.c2
-rw-r--r--src/interface/efi/efi_path.c8
2 files changed, 5 insertions, 5 deletions
diff --git a/src/interface/efi/efi_local.c b/src/interface/efi/efi_local.c
index 4ebca57..d8edb62 100644
--- a/src/interface/efi/efi_local.c
+++ b/src/interface/efi/efi_local.c
@@ -425,7 +425,7 @@ static int efi_local_open_resolved ( struct efi_local *local,
static int efi_local_open_path ( struct efi_local *local, const char *path ) {
FILEPATH_DEVICE_PATH *fp = container_of ( efi_loaded_image->FilePath,
FILEPATH_DEVICE_PATH, Header);
- size_t fp_len = ( fp ? efi_path_len ( &fp->Header ) : 0 );
+ size_t fp_len = efi_path_len ( &fp->Header );
char base[ fp_len / 2 /* Cannot exceed this length */ ];
size_t remaining = sizeof ( base );
size_t len;
diff --git a/src/interface/efi/efi_path.c b/src/interface/efi/efi_path.c
index bae0ac4..1a95a3b 100644
--- a/src/interface/efi/efi_path.c
+++ b/src/interface/efi/efi_path.c
@@ -43,12 +43,12 @@
/**
* Find end of device path
*
- * @v path Path to device
- * @ret path_end End of device path
+ * @v path Device path, or NULL
+ * @ret path_end End of device path, or NULL
*/
EFI_DEVICE_PATH_PROTOCOL * efi_path_end ( EFI_DEVICE_PATH_PROTOCOL *path ) {
- while ( path->Type != END_DEVICE_PATH_TYPE ) {
+ while ( path && ( path->Type != END_DEVICE_PATH_TYPE ) ) {
path = ( ( ( void * ) path ) +
/* There's this amazing new-fangled thing known as
* a UINT16, but who wants to use one of those? */
@@ -61,7 +61,7 @@ EFI_DEVICE_PATH_PROTOCOL * efi_path_end ( EFI_DEVICE_PATH_PROTOCOL *path ) {
/**
* Find length of device path (excluding terminator)
*
- * @v path Path to device
+ * @v path Device path, or NULL
* @ret path_len Length of device path
*/
size_t efi_path_len ( EFI_DEVICE_PATH_PROTOCOL *path ) {