On 11.01.18 08:16, Heinrich Schuchardt wrote:
> efi_open_protocol_information provides the agent and controller
> handles as well as the attributes and open count of an protocol
> on a handle.
> 
> Signed-off-by: Heinrich Schuchardt <[email protected]>
> ---
> v3
>       no change
> v2
>       no change
> ---
>  lib/efi_loader/efi_boottime.c | 41 ++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 40 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
> index a527e33141..44c9da0a7c 100644
> --- a/lib/efi_loader/efi_boottime.c
> +++ b/lib/efi_loader/efi_boottime.c
> @@ -1722,9 +1722,48 @@ static efi_status_t EFIAPI 
> efi_open_protocol_information(efi_handle_t handle,
>                       struct efi_open_protocol_info_entry **entry_buffer,
>                       efi_uintn_t *entry_count)
>  {
> +     unsigned long buffer_size;
> +     unsigned long count;
> +     struct efi_handler *handler;
> +     struct efi_open_protocol_info_item *item;
> +     efi_status_t r;
> +
>       EFI_ENTRY("%p, %pUl, %p, %p", handle, protocol, entry_buffer,
>                 entry_count);
> -     return EFI_EXIT(EFI_NOT_FOUND);
> +
> +     /* Check parameters */
> +     if (!entry_buffer) {
> +             r = EFI_INVALID_PARAMETER;
> +             goto out;
> +     }
> +     r = efi_search_protocol(handle, protocol, &handler);
> +     if (r != EFI_SUCCESS)
> +             goto out;
> +
> +     /* Count entries */
> +     count = 0;
> +     list_for_each_entry(item, &handler->open_infos, link) {
> +             ++count;

^

> +     }
> +     *entry_count = count;
> +     *entry_buffer = NULL;
> +     if (!count) {
> +             r = EFI_SUCCESS;
> +             goto out;
> +     }
> +
> +     /* Copy entries */
> +     buffer_size = count * sizeof(struct efi_open_protocol_info_entry);
> +     r = efi_allocate_pool(EFI_ALLOCATE_ANY_PAGES, buffer_size,
> +                           (void **)entry_buffer);
> +     if (r != EFI_SUCCESS)
> +             goto out;
> +     list_for_each_entry_reverse(item, &handler->open_infos, link) {
> +             if (item->info.open_count)
> +                     (*entry_buffer)[--count] = item->info;

The count resulting here is different from the first count, as here you
also check item->info.open_count. Shouldn't that also get checked above?


Alex

> +     }
> +out:
> +     return EFI_EXIT(r);
>  }
>  
>  /*
> 
_______________________________________________
U-Boot mailing list
[email protected]
https://lists.denx.de/listinfo/u-boot

Reply via email to