ACK: [PATCH 2/2] efi_runtime: handle memory errors when setting variables

Alex Hung alex.hung at canonical.com
Mon Mar 2 02:54:13 UTC 2015


On 02/12/2015 04:43 AM, Ricardo Neri wrote:
> If the allocation of data fails, we must not proceed copying data
> from the user space. Instead we return with -ENOMEM.
> 
> Also, while there, free the memory of the variable name in case
> the copy from user space fails.
> 
> Reported-by: Colin Ian King <colin.king at canonical.com>
> Signed-off-by: Ricardo Neri <ricardo.neri-calderon at linux.intel.com>
> ---
>  efi_runtime/efi_runtime.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/efi_runtime/efi_runtime.c b/efi_runtime/efi_runtime.c
> index 1125556..9693721 100644
> --- a/efi_runtime/efi_runtime.c
> +++ b/efi_runtime/efi_runtime.c
> @@ -300,8 +300,13 @@ static long efi_runtime_set_variable(unsigned long arg)
>  		return rv;
>  
>  	data = kmalloc(psetvariable_local.DataSize, GFP_KERNEL);
> +	if (!data) {
> +		kfree(name);
> +		return -ENOMEM;
> +	}
>  	if (copy_from_user(data, psetvariable_local.Data,
>  			   psetvariable_local.DataSize)) {
> +		kfree(data);
>  		kfree(name);
>  		return -EFAULT;
>  	}
> 

Acked-by: Alex Hung <alex.hung at canonical.com>



More information about the fwts-devel mailing list