Commit 5d25fde2 authored by Shyam Saini's avatar Shyam Saini Committed by Sinclair Yeh

drm/vmwgfx: Use kmemdup instead of kmalloc and memcpy

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: default avatarShyam Saini <mayhs11saini@gmail.com>
Reviewed-by: default avatarSinclair Yeh <syeh@vmare.com>
parent 8c95742e
...@@ -319,18 +319,17 @@ int vmw_otables_setup(struct vmw_private *dev_priv) ...@@ -319,18 +319,17 @@ int vmw_otables_setup(struct vmw_private *dev_priv)
int ret; int ret;
if (dev_priv->has_dx) { if (dev_priv->has_dx) {
*otables = kmalloc(sizeof(dx_tables), GFP_KERNEL); *otables = kmemdup(dx_tables, sizeof(dx_tables), GFP_KERNEL);
if (*otables == NULL) if (*otables == NULL)
return -ENOMEM; return -ENOMEM;
memcpy(*otables, dx_tables, sizeof(dx_tables));
dev_priv->otable_batch.num_otables = ARRAY_SIZE(dx_tables); dev_priv->otable_batch.num_otables = ARRAY_SIZE(dx_tables);
} else { } else {
*otables = kmalloc(sizeof(pre_dx_tables), GFP_KERNEL); *otables = kmemdup(pre_dx_tables, sizeof(pre_dx_tables),
GFP_KERNEL);
if (*otables == NULL) if (*otables == NULL)
return -ENOMEM; return -ENOMEM;
memcpy(*otables, pre_dx_tables, sizeof(pre_dx_tables));
dev_priv->otable_batch.num_otables = ARRAY_SIZE(pre_dx_tables); dev_priv->otable_batch.num_otables = ARRAY_SIZE(pre_dx_tables);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment