device_path_to_filepath may be called on a device pth that contains no
file path. In that case, the function should return NULL instead of
dereferencing the NULL pointer. Fix this.

Fixes: f1230c7f92cd ("efi: payload: dynamically determine bootloader file name")
Signed-off-by: Ahmad Fatoum <a.fat...@pengutronix.de>
---
 efi/devicepath.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/efi/devicepath.c b/efi/devicepath.c
index 23963aa0cbb7..ecb3e7b64cc1 100644
--- a/efi/devicepath.c
+++ b/efi/devicepath.c
@@ -824,6 +824,9 @@ char *device_path_to_filepath(const struct efi_device_path 
*dev_path)
                dev_path = next_device_path_node(&fp->header);
        }
 
+       if (!fp)
+               return NULL;
+
        path = strdup_wchar_to_char(fp->path_name);
        if (!path)
                return NULL;
-- 
2.39.2


Reply via email to