aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdkfd
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2016-01-02 15:06:19 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2016-01-06 08:25:25 -0500
commit8f1d57c172482c9a1568ec647fc5c2e64c6c6a57 (patch)
tree31680b16a1c572acfc17315af6eb45b3cbb810c8 /drivers/gpu/drm/amd/amdkfd
parentabb0f6a79fe8eba7982b73313b8623259d78c3f6 (diff)
amdkfd: don't open-code memdup_user()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'drivers/gpu/drm/amd/amdkfd')
-rw-r--r--drivers/gpu/drm/amd/amdkfd/kfd_chardev.c33
1 files changed, 7 insertions, 26 deletions
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
index c6a1b4cc6458..d321222fd92e 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
@@ -559,19 +559,10 @@ static int kfd_ioctl_dbg_address_watch(struct file *filep,
559 559
560 /* this is the actual buffer to work with */ 560 /* this is the actual buffer to work with */
561 561
562 args_buff = kmalloc(args->buf_size_in_bytes - 562 args_buff = memdup_user(args_buff,
563 sizeof(*args), GFP_KERNEL);
564 if (args_buff == NULL)
565 return -ENOMEM;
566
567 status = copy_from_user(args_buff, cmd_from_user,
568 args->buf_size_in_bytes - sizeof(*args)); 563 args->buf_size_in_bytes - sizeof(*args));
569 564 if (IS_ERR(args_buff))
570 if (status != 0) { 565 return PTR_ERR(args_buff);
571 pr_debug("Failed to copy address watch user data\n");
572 kfree(args_buff);
573 return -EINVAL;
574 }
575 566
576 aw_info.process = p; 567 aw_info.process = p;
577 568
@@ -677,22 +668,12 @@ static int kfd_ioctl_dbg_wave_control(struct file *filep,
677 if (cmd_from_user == NULL) 668 if (cmd_from_user == NULL)
678 return -EINVAL; 669 return -EINVAL;
679 670
680 /* this is the actual buffer to work with */ 671 /* copy the entire buffer from user */
681 672
682 args_buff = kmalloc(args->buf_size_in_bytes - sizeof(*args), 673 args_buff = memdup_user(cmd_from_user,
683 GFP_KERNEL);
684
685 if (args_buff == NULL)
686 return -ENOMEM;
687
688 /* Now copy the entire buffer from user */
689 status = copy_from_user(args_buff, cmd_from_user,
690 args->buf_size_in_bytes - sizeof(*args)); 674 args->buf_size_in_bytes - sizeof(*args));
691 if (status != 0) { 675 if (IS_ERR(args_buff))
692 pr_debug("Failed to copy wave control user data\n"); 676 return PTR_ERR(args_buff);
693 kfree(args_buff);
694 return -EINVAL;
695 }
696 677
697 /* move ptr to the start of the "pay-load" area */ 678 /* move ptr to the start of the "pay-load" area */
698 wac_info.process = p; 679 wac_info.process = p;