[PATCH] efi_runtime: Use memdup_user helper

Colin Ian King colin.king at canonical.com
Mon Jul 3 07:54:09 UTC 2017


On 03/07/17 08:48, 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;
>  }
>  
> 
Ivan, this is great for the latest kernel, what do we do for backwards
compatibility in the fwts DKMS driver?

Acked-by: Colin Ian King <colin.king at canonical.com>



More information about the fwts-devel mailing list