device_path_next_compatible_node() returns the matching node itself and
doesn't advance past it, so the continue in device_path_to_partuuid()
re-enters the search with the same device path. A hard drive node whose
signature type is neither MBR nor GUID, which the UEFI specification
allows as "No Disk Signature", hangs the search in an endless loop instead
of moving on to the next node.

Advance to the next node before searching again, the way
device_path_to_filepath() does.

Assisted-by: Claude:opus-5
Signed-off-by: Ahmad Fatoum <[email protected]>
---
 efi/devicepath.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/efi/devicepath.c b/efi/devicepath.c
index 32ddc952cd9b..fd2ad9d580c2 100644
--- a/efi/devicepath.c
+++ b/efi/devicepath.c
@@ -810,11 +810,11 @@ char *device_path_to_partuuid(const struct 
efi_device_path *dev_path)
                struct efi_device_path_hard_drive_path *hd =
                        (struct efi_device_path_hard_drive_path *)dev_path;
 
-               if (hd->signature_type != SIGNATURE_TYPE_GUID &&
-                   hd->signature_type != SIGNATURE_TYPE_MBR)
-                       continue;
+               if (hd->signature_type == SIGNATURE_TYPE_GUID ||
+                   hd->signature_type == SIGNATURE_TYPE_MBR)
+                       return xasprintf("%pUl", (efi_guid_t 
*)&(hd->signature[0]));
 
-               return xasprintf("%pUl", (efi_guid_t *)&(hd->signature[0]));
+               dev_path = next_device_path_node(dev_path);
        }
 
        return NULL;
-- 
2.47.3


Reply via email to