diff options
author | Shyam Saini <mayhs11saini@gmail.com> | 2017-01-19 16:45:34 -0500 |
---|---|---|
committer | Sinclair Yeh <syeh@vmware.com> | 2017-01-27 00:26:17 -0500 |
commit | 5d25fde23b3176c7f94d2a992cb9762707d7c2a0 (patch) | |
tree | 0a2398da4b68335d045d3ebd46145ddfac607eab | |
parent | 8c95742e566f3945f992472a5f99f78aaa7f890b (diff) |
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: Shyam Saini <mayhs11saini@gmail.com>
Reviewed-by: Sinclair Yeh <syeh@vmare.com>
-rw-r--r-- | drivers/gpu/drm/vmwgfx/vmwgfx_mob.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_mob.c b/drivers/gpu/drm/vmwgfx/vmwgfx_mob.c index b6126a5f1269..941bcfd131ff 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) | |||
319 | int ret; | 319 | int ret; |
320 | 320 | ||
321 | if (dev_priv->has_dx) { | 321 | if (dev_priv->has_dx) { |
322 | *otables = kmalloc(sizeof(dx_tables), GFP_KERNEL); | 322 | *otables = kmemdup(dx_tables, sizeof(dx_tables), GFP_KERNEL); |
323 | if (*otables == NULL) | 323 | if (*otables == NULL) |
324 | return -ENOMEM; | 324 | return -ENOMEM; |
325 | 325 | ||
326 | memcpy(*otables, dx_tables, sizeof(dx_tables)); | ||
327 | dev_priv->otable_batch.num_otables = ARRAY_SIZE(dx_tables); | 326 | dev_priv->otable_batch.num_otables = ARRAY_SIZE(dx_tables); |
328 | } else { | 327 | } else { |
329 | *otables = kmalloc(sizeof(pre_dx_tables), GFP_KERNEL); | 328 | *otables = kmemdup(pre_dx_tables, sizeof(pre_dx_tables), |
329 | GFP_KERNEL); | ||
330 | if (*otables == NULL) | 330 | if (*otables == NULL) |
331 | return -ENOMEM; | 331 | return -ENOMEM; |
332 | 332 | ||
333 | memcpy(*otables, pre_dx_tables, sizeof(pre_dx_tables)); | ||
334 | dev_priv->otable_batch.num_otables = ARRAY_SIZE(pre_dx_tables); | 333 | dev_priv->otable_batch.num_otables = ARRAY_SIZE(pre_dx_tables); |
335 | } | 334 | } |
336 | 335 | ||