Re: [PATCH] gpu: drm: vmwgfx: Use kmemdup instead of kmalloc and memcpy

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks, applied.

Reviewed-by: Sinclair Yeh <syeh@xxxxxxxxxx>


On Sat, Dec 24, 2016 at 01:21:10AM +0530, Shyam Saini wrote:
> When some other buffer is immediately copied into allocated region.
> Replace calls to kmalloc followed by a memcpy with a direct
> call to kmemdup.
> 
> Signed-off-by: Shyam Saini <mayhs11saini@xxxxxxxxx>
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_mob.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_mob.c b/drivers/gpu/drm/vmwgfx/vmwgfx_mob.c
> index b6126a5..941bcfd 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_mob.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_mob.c
> @@ -319,18 +319,17 @@ int vmw_otables_setup(struct vmw_private *dev_priv)
>  	int ret;
>  
>  	if (dev_priv->has_dx) {
> -		*otables = kmalloc(sizeof(dx_tables), GFP_KERNEL);
> +		*otables = kmemdup(dx_tables, sizeof(dx_tables), GFP_KERNEL);
>  		if (*otables == NULL)
>  			return -ENOMEM;
>  
> -		memcpy(*otables, dx_tables, sizeof(dx_tables));
>  		dev_priv->otable_batch.num_otables = ARRAY_SIZE(dx_tables);
>  	} else {
> -		*otables = kmalloc(sizeof(pre_dx_tables), GFP_KERNEL);
> +		*otables = kmemdup(pre_dx_tables, sizeof(pre_dx_tables),
> +				   GFP_KERNEL);
>  		if (*otables == NULL)
>  			return -ENOMEM;
>  
> -		memcpy(*otables, pre_dx_tables, sizeof(pre_dx_tables));
>  		dev_priv->otable_batch.num_otables = ARRAY_SIZE(pre_dx_tables);
>  	}
>  
> -- 
> 2.7.4
> 
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux