summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/savage
diff options
context:
space:
mode:
authorMarkus Elfring <elfring@users.sourceforge.net>2016-08-18 18:12:03 +0200
committerDaniel Vetter <daniel.vetter@ffwll.ch>2016-08-19 10:58:55 +0200
commita6e3918bcdb1253083f962d747ec699bdb4bacd9 (patch)
treed0831ef137c59c1e337668e1d996f4b9df4e0122 /drivers/gpu/drm/savage
parentdrm: Allow drivers to modify plane_state in prepare_fb/cleanup_fb (diff)
downloadlinux-a6e3918bcdb1253083f962d747ec699bdb4bacd9.tar.xz
linux-a6e3918bcdb1253083f962d747ec699bdb4bacd9.zip
GPU-DRM-Savage: Use memdup_user() rather than duplicating
Reuse existing functionality from memdup_user() instead of keeping duplicate source code. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: http://patchwork.freedesktop.org/patch/msgid/021efa32-c259-e799-a80e-630972291815@users.sourceforge.net
Diffstat (limited to 'drivers/gpu/drm/savage')
-rw-r--r--drivers/gpu/drm/savage/savage_state.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/drivers/gpu/drm/savage/savage_state.c b/drivers/gpu/drm/savage/savage_state.c
index c01ad0aeaa58..3dc0d8ff95ec 100644
--- a/drivers/gpu/drm/savage/savage_state.c
+++ b/drivers/gpu/drm/savage/savage_state.c
@@ -1001,15 +1001,9 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_
cmdbuf->cmd_addr = kcmd_addr;
}
if (cmdbuf->vb_size) {
- kvb_addr = kmalloc(cmdbuf->vb_size, GFP_KERNEL);
- if (kvb_addr == NULL) {
- ret = -ENOMEM;
- goto done;
- }
-
- if (copy_from_user(kvb_addr, cmdbuf->vb_addr,
- cmdbuf->vb_size)) {
- ret = -EFAULT;
+ kvb_addr = memdup_user(cmdbuf->vb_addr, cmdbuf->vb_size);
+ if (IS_ERR(kvb_addr)) {
+ ret = PTR_ERR(kvb_addr);
goto done;
}
cmdbuf->vb_addr = kvb_addr;