ACK: [PATCH] efi_runtime: Use memdup_user helper

Alex Hung alex.hung at canonical.com
Tue Jul 4 08:11:48 UTC 2017


On 2017-07-03 12:48 AM, Ivan Hu wrote:
> From: Geliang Tang <geliangtang at gmail.com>
> 
> Sync up with kernel driver efi_test:
> 
> efi/efi_test: Use memdup_user() helper
> 
> Use memdup_user() helper instead of open-coding to simplify the code.
> 
> Signed-off-by: Geliang Tang <geliangtang at gmail.com>
> Signed-off-by: Ivan Hu <ivan.hu at canonical.com>
> ---
>   efi_runtime/efi_runtime.c | 11 +++--------
>   1 file changed, 3 insertions(+), 8 deletions(-)
> 
> diff --git a/efi_runtime/efi_runtime.c b/efi_runtime/efi_runtime.c
> index 19b624c..6570a54 100644
> --- a/efi_runtime/efi_runtime.c
> +++ b/efi_runtime/efi_runtime.c
> @@ -90,18 +90,13 @@ copy_ucs2_from_user_len(efi_char16_t **dst, efi_char16_t __user *src,
>   	if (!access_ok(VERIFY_READ, src, 1))
>   		return -EFAULT;
>   
> -	buf = kmalloc(len, GFP_KERNEL);
> -	if (!buf) {
> +	buf = memdup_user(src, len);
> +	if (IS_ERR(buf)) {
>   		*dst = NULL;
> -		return -ENOMEM;
> +		return PTR_ERR(buf);
>   	}
>   	*dst = buf;
>   
> -	if (copy_from_user(*dst, src, len)) {
> -		kfree(buf);
> -		return -EFAULT;
> -	}
> -
>   	return 0;
>   }
>   
> 
Acked-by: Alex Hung <alex.hung at canonical.com>



More information about the fwts-devel mailing list