diff mbox

efiruntime: getnextvariablename update the VariableNameSize before return when get EFI_BUFFER_TOO_SMALL

Message ID 1364809003-7402-1-git-send-email-ivan.hu@canonical.com
State Accepted
Headers show

Commit Message

Ivan Hu April 1, 2013, 9:36 a.m. UTC
The UEFI variable test on fwts, we test the getnextvariable implementation that
when EFI_BUFFER_TOO_SMALL error occurs, the VariableNameSize is updated to
reflect the size of buffer needed.
When EFI_BUFFER_TOO_SMALL error occurs, efi_runtime need to first update the the
VariableNameSize, then return error code. so move the return error code later than update code.

Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
---
 efi_runtime/efi_runtime.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Colin Ian King April 1, 2013, 10:31 a.m. UTC | #1
On 01/04/13 10:36, Ivan Hu wrote:
> The UEFI variable test on fwts, we test the getnextvariable implementation that
> when EFI_BUFFER_TOO_SMALL error occurs, the VariableNameSize is updated to
> reflect the size of buffer needed.
> When EFI_BUFFER_TOO_SMALL error occurs, efi_runtime need to first update the the
> VariableNameSize, then return error code. so move the return error code later than update code.
> 
> Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
> ---
>  efi_runtime/efi_runtime.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/efi_runtime/efi_runtime.c b/efi_runtime/efi_runtime.c
> index 9440aae..db4a465 100644
> --- a/efi_runtime/efi_runtime.c
> +++ b/efi_runtime/efi_runtime.c
> @@ -256,8 +256,6 @@ static long efi_runtime_ioctl(struct file *file, unsigned int cmd,
>  								&vendor);
>  		if (put_user(status, pgetnextvariablename->status))
>  			return -EFAULT;
> -		if (status != EFI_SUCCESS)
> -			return -EINVAL;
>  		convert_to_guid(&vendor, &vendor_guid);
>  
>  		if (put_user(name_size, pgetnextvariablename->VariableNameSize))
> @@ -266,6 +264,8 @@ static long efi_runtime_ioctl(struct file *file, unsigned int cmd,
>  		if (copy_to_user(pgetnextvariablename->VendorGuid,
>  						&vendor_guid, sizeof(EFI_GUID)))
>  			return -EFAULT;
> +		if (status != EFI_SUCCESS)
> +			return -EINVAL;
>  		return 0;
>  
>  	case EFI_RUNTIME_QUERY_VARIABLEINFO:
> 
Acked-by: Colin Ian King <colin.king@canonical.com>
Alex Hung April 1, 2013, 3:02 p.m. UTC | #2
On 04/01/2013 05:36 PM, Ivan Hu wrote:
> The UEFI variable test on fwts, we test the getnextvariable implementation that
> when EFI_BUFFER_TOO_SMALL error occurs, the VariableNameSize is updated to
> reflect the size of buffer needed.
> When EFI_BUFFER_TOO_SMALL error occurs, efi_runtime need to first update the the
> VariableNameSize, then return error code. so move the return error code later than update code.
>
> Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
> ---
>   efi_runtime/efi_runtime.c |    4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/efi_runtime/efi_runtime.c b/efi_runtime/efi_runtime.c
> index 9440aae..db4a465 100644
> --- a/efi_runtime/efi_runtime.c
> +++ b/efi_runtime/efi_runtime.c
> @@ -256,8 +256,6 @@ static long efi_runtime_ioctl(struct file *file, unsigned int cmd,
>   								&vendor);
>   		if (put_user(status, pgetnextvariablename->status))
>   			return -EFAULT;
> -		if (status != EFI_SUCCESS)
> -			return -EINVAL;
>   		convert_to_guid(&vendor, &vendor_guid);
>
>   		if (put_user(name_size, pgetnextvariablename->VariableNameSize))
> @@ -266,6 +264,8 @@ static long efi_runtime_ioctl(struct file *file, unsigned int cmd,
>   		if (copy_to_user(pgetnextvariablename->VendorGuid,
>   						&vendor_guid, sizeof(EFI_GUID)))
>   			return -EFAULT;
> +		if (status != EFI_SUCCESS)
> +			return -EINVAL;
>   		return 0;
>
>   	case EFI_RUNTIME_QUERY_VARIABLEINFO:
>
Acked-by: Alex Hung <alex.hung@canonical.com>
diff mbox

Patch

diff --git a/efi_runtime/efi_runtime.c b/efi_runtime/efi_runtime.c
index 9440aae..db4a465 100644
--- a/efi_runtime/efi_runtime.c
+++ b/efi_runtime/efi_runtime.c
@@ -256,8 +256,6 @@  static long efi_runtime_ioctl(struct file *file, unsigned int cmd,
 								&vendor);
 		if (put_user(status, pgetnextvariablename->status))
 			return -EFAULT;
-		if (status != EFI_SUCCESS)
-			return -EINVAL;
 		convert_to_guid(&vendor, &vendor_guid);
 
 		if (put_user(name_size, pgetnextvariablename->VariableNameSize))
@@ -266,6 +264,8 @@  static long efi_runtime_ioctl(struct file *file, unsigned int cmd,
 		if (copy_to_user(pgetnextvariablename->VendorGuid,
 						&vendor_guid, sizeof(EFI_GUID)))
 			return -EFAULT;
+		if (status != EFI_SUCCESS)
+			return -EINVAL;
 		return 0;
 
 	case EFI_RUNTIME_QUERY_VARIABLEINFO: