public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: AKASHI Takahiro <takahiro.akashi@linaro.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/1] efi_loader: ListPackageLists() return EFI_NOT_FOUND
Date: Tue, 18 Jun 2019 09:44:58 +0900	[thread overview]
Message-ID: <20190618004457.GE6610@linaro.org> (raw)
In-Reply-To: <20190617190246.32188-1-xypron.glpk@gmx.de>

On Mon, Jun 17, 2019 at 09:02:46PM +0200, Heinrich Schuchardt wrote:
> If no matching package list is found in ListPackageLists(), return
> EFI_NOT_FOUND.
> 
> If we do not support a package type, we can immediately leave the function.

This won't happen because add_packages() eliminates all unsupported
packages.

> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
>  lib/efi_loader/efi_hii.c | 34 ++++++++++++++++++++--------------
>  1 file changed, 20 insertions(+), 14 deletions(-)
> 
> diff --git a/lib/efi_loader/efi_hii.c b/lib/efi_loader/efi_hii.c
> index 61b71dec62..8ce526e1c8 100644
> --- a/lib/efi_loader/efi_hii.c
> +++ b/lib/efi_loader/efi_hii.c
> @@ -581,18 +581,22 @@ list_package_lists(const struct efi_hii_database_protocol *this,
>  	struct efi_hii_packagelist *hii =
>  				(struct efi_hii_packagelist *)handle;
>  	int package_cnt, package_max;
> -	efi_status_t ret = EFI_SUCCESS;
> +	efi_status_t ret = EFI_NOT_FOUND;
> 
>  	EFI_ENTRY("%p, %u, %pUl, %p, %p", this, package_type, package_guid,
>  		  handle_buffer_length, handle);
> 
>  	if (!handle_buffer_length ||
> -	    (*handle_buffer_length && !handle))
> -		return EFI_EXIT(EFI_INVALID_PARAMETER);
> +	    (*handle_buffer_length && !handle)) {
> +		ret = EFI_INVALID_PARAMETER;
> +		goto out;
> +	}
> 
>  	if ((package_type != EFI_HII_PACKAGE_TYPE_GUID && package_guid) ||
> -	    (package_type == EFI_HII_PACKAGE_TYPE_GUID && !package_guid))
> -		return EFI_EXIT(EFI_INVALID_PARAMETER);
> +	    (package_type == EFI_HII_PACKAGE_TYPE_GUID && !package_guid)) {
> +		ret = EFI_INVALID_PARAMETER;
> +		goto out;
> +	}
> 
>  	EFI_PRINT("package type=%x, guid=%pUl, length=%zu\n", (int)package_type,
>  		  package_guid, *handle_buffer_length);
> @@ -610,7 +614,7 @@ list_package_lists(const struct efi_hii_database_protocol *this,
>  		case EFI_HII_PACKAGE_FORMS:
>  			EFI_PRINT("Form package not supported\n");
>  			ret = EFI_INVALID_PARAMETER;
> -			continue;
> +			goto out;
>  		case EFI_HII_PACKAGE_STRINGS:
>  			if (!list_empty(&hii->string_tables))
>  				break;
> @@ -618,19 +622,19 @@ list_package_lists(const struct efi_hii_database_protocol *this,
>  		case EFI_HII_PACKAGE_FONTS:
>  			EFI_PRINT("Font package not supported\n");
>  			ret = EFI_INVALID_PARAMETER;
> -			continue;
> +			goto out;
>  		case EFI_HII_PACKAGE_IMAGES:
>  			EFI_PRINT("Image package not supported\n");
>  			ret = EFI_INVALID_PARAMETER;
> -			continue;
> +			goto out;
>  		case EFI_HII_PACKAGE_SIMPLE_FONTS:
>  			EFI_PRINT("Simple font package not supported\n");
>  			ret = EFI_INVALID_PARAMETER;
> -			continue;
> +			goto out;
>  		case EFI_HII_PACKAGE_DEVICE_PATH:
>  			EFI_PRINT("Device path package not supported\n");
>  			ret = EFI_INVALID_PARAMETER;
> -			continue;
> +			goto out;
>  		case EFI_HII_PACKAGE_KEYBOARD_LAYOUT:
>  			if (!list_empty(&hii->keyboard_packages))
>  				break;
> @@ -638,7 +642,7 @@ list_package_lists(const struct efi_hii_database_protocol *this,
>  		case EFI_HII_PACKAGE_ANIMATIONS:
>  			EFI_PRINT("Animation package not supported\n");
>  			ret = EFI_INVALID_PARAMETER;
> -			continue;
> +			goto out;
>  		case EFI_HII_PACKAGE_END:
>  		case EFI_HII_PACKAGE_TYPE_SYSTEM_BEGIN:
>  		case EFI_HII_PACKAGE_TYPE_SYSTEM_END:
> @@ -647,13 +651,15 @@ list_package_lists(const struct efi_hii_database_protocol *this,
>  		}
> 
>  		package_cnt++;
> -		if (package_cnt <= package_max)
> +		if (package_cnt <= package_max) {
>  			*handle++ = hii;
> -		else
> +			ret = EFI_SUCCESS;
> +		} else {
>  			ret = EFI_BUFFER_TOO_SMALL;
> +		}

It will be enough that this check be done only once at the end of
this function.

>  	}
>  	*handle_buffer_length = package_cnt * sizeof(*handle);

here,
        if (package_cnt > package_max)
                ret = EFI_BUFFER_TOO_SMALL;

- Takahiro Akashi

> -
> +out:
>  	return EFI_EXIT(ret);
>  }
> 
> --
> 2.20.1
> 

  reply	other threads:[~2019-06-18  0:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-17 19:02 [U-Boot] [PATCH 1/1] efi_loader: ListPackageLists() return EFI_NOT_FOUND Heinrich Schuchardt
2019-06-18  0:44 ` AKASHI Takahiro [this message]
2019-06-18  5:41   ` Heinrich Schuchardt
2019-06-18  5:58   ` Heinrich Schuchardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190618004457.GE6610@linaro.org \
    --to=takahiro.akashi@linaro.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox