]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
boot: Don't copy device path
authorJan Janssen <medhefgo@web.de>
Sun, 29 May 2022 09:03:43 +0000 (11:03 +0200)
committerJan Janssen <medhefgo@web.de>
Thu, 9 Jun 2022 10:50:13 +0000 (12:50 +0200)
BS->LocateDevicePath only advances the passed device path pointer.
It does not actually modify it, so there is no need to make a copy.

src/boot/efi/shim.c

index 663eafbae41839690482231cb6e952c2ea8d8ee7..20db89817a88e7e1c51dcb8ea076e0c5faee9fbe 100644 (file)
@@ -102,7 +102,6 @@ static EFIAPI EFI_STATUS security2_policy_authentication (const EFI_SECURITY2_PR
 static EFIAPI EFI_STATUS security_policy_authentication (const EFI_SECURITY_PROTOCOL *this, UINT32 authentication_status,
                                                          const EFI_DEVICE_PATH_PROTOCOL *device_path_const) {
         EFI_STATUS status;
-        _cleanup_freepool_ EFI_DEVICE_PATH *dev_path = NULL;
         _cleanup_freepool_ CHAR16 *dev_path_str = NULL;
         EFI_HANDLE h;
         _cleanup_freepool_ CHAR8 *file_buffer = NULL;
@@ -113,11 +112,7 @@ static EFIAPI EFI_STATUS security_policy_authentication (const EFI_SECURITY_PROT
         if (!device_path_const)
                 return EFI_INVALID_PARAMETER;
 
-        dev_path = DuplicateDevicePath((EFI_DEVICE_PATH*) device_path_const);
-        if (!dev_path)
-                return EFI_OUT_OF_RESOURCES;
-
-        EFI_DEVICE_PATH *dp = dev_path;
+        EFI_DEVICE_PATH *dp = (EFI_DEVICE_PATH *) device_path_const;
         status = BS->LocateDevicePath(&FileSystemProtocol, &dp, &h);
         if (EFI_ERROR(status))
                 return status;