]> git.ipfire.org Git - thirdparty/u-boot.git/blobdiff - lib/efi_loader/efi_boottime.c
efi_loader: CloseProtocol() requires valid agent handle
[thirdparty/u-boot.git] / lib / efi_loader / efi_boottime.c
index 194df5a180db14a0e532478ae3d21689e099bfe0..967b39b223ce2e12d8cecc64ef88950bc30c2153 100644 (file)
@@ -971,11 +971,13 @@ struct efi_object *efi_search_obj(const efi_handle_t handle)
 {
        struct efi_object *efiobj;
 
+       if (!handle)
+               return NULL;
+
        list_for_each_entry(efiobj, &efi_obj_list, link) {
                if (efiobj == handle)
                        return efiobj;
        }
-
        return NULL;
 }
 
@@ -1982,7 +1984,8 @@ static efi_status_t EFIAPI efi_close_protocol(efi_handle_t handle,
        EFI_ENTRY("%p, %pUl, %p, %p", handle, protocol, agent_handle,
                  controller_handle);
 
-       if (!agent_handle) {
+       if (!efi_search_obj(agent_handle) ||
+           (controller_handle && !efi_search_obj(controller_handle))) {
                r = EFI_INVALID_PARAMETER;
                goto out;
        }