ACK: [PATCH 4/6] efi_runtime: refactor the success and error path
Colin Ian King
colin.king at canonical.com
Fri Aug 19 07:58:15 UTC 2016
On 19/08/16 03:57, Ivan Hu wrote:
> Signed-off-by: Ivan Hu <ivan.hu at canonical.com>
> ---
> efi_runtime/efi_runtime.c | 40 ++++++++++++++++++++--------------------
> 1 file changed, 20 insertions(+), 20 deletions(-)
>
> diff --git a/efi_runtime/efi_runtime.c b/efi_runtime/efi_runtime.c
> index 5dead14..ceb655d 100644
> --- a/efi_runtime/efi_runtime.c
> +++ b/efi_runtime/efi_runtime.c
> @@ -218,32 +218,32 @@ static long efi_runtime_get_variable(unsigned long arg)
> status = efi.get_variable(name, vd, at, dz, data);
> kfree(name);
>
> - if (data) {
> - if (status == EFI_SUCCESS && prev_datasize >= datasize)
> - rv = copy_to_user(getvariable.data, data,
> - datasize);
> - kfree(data);
> - }
> -
> - if (rv)
> - return rv;
> -
> if (put_user(status, getvariable.status))
> return -EFAULT;
> - if (status == EFI_SUCCESS && prev_datasize >= datasize) {
> - if (at && put_user(attr, getvariable.attributes))
> - return -EFAULT;
> - if (dz && put_user(datasize, getvariable.data_size))
> - return -EFAULT;
> - return 0;
> - } else if (status == EFI_BUFFER_TOO_SMALL) {
> - if (dz && put_user(datasize, getvariable.data_size))
> - return -EFAULT;
> +
> + if (status != EFI_SUCCESS) {
> + if (status == EFI_BUFFER_TOO_SMALL) {
> + if (dz && put_user(datasize, getvariable.data_size))
> + return -EFAULT;
> + }
> return -EINVAL;
> - } else {
> + }
> +
> + if (prev_datasize < datasize)
> return -EINVAL;
> +
> + if (data) {
> + rv = copy_to_user(getvariable.data, data, datasize);
> + kfree(data);
> + if (rv)
> + return rv;
> }
>
> + if (at && put_user(attr, getvariable.attributes))
> + return -EFAULT;
> + if (dz && put_user(datasize, getvariable.data_size))
> + return -EFAULT;
> +
> return 0;
> }
>
>
Looks OK to me.
Acked-by: Colin Ian King <colin.king at canonical.com>
More information about the fwts-devel
mailing list