[PATCH] efiruntime: getnextvariablename update the VariableNameSize before return when get EFI_BUFFER_TOO_SMALL
Ivan Hu
ivan.hu at canonical.com
Mon Apr 1 09:36:43 UTC 2013
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 at 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:
--
1.7.10.4
More information about the fwts-devel
mailing list