aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/gpu/drm/drm_ioctl.c39
1 files changed, 15 insertions, 24 deletions
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index fc0cf4a84011..68ba014886c2 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -663,39 +663,30 @@ long drm_ioctl(struct file *filp,
663 int retcode = -EINVAL; 663 int retcode = -EINVAL;
664 char stack_kdata[128]; 664 char stack_kdata[128];
665 char *kdata = NULL; 665 char *kdata = NULL;
666 unsigned int usize, asize; 666 unsigned int usize, asize, drv_size;
667 667
668 dev = file_priv->minor->dev; 668 dev = file_priv->minor->dev;
669 669
670 if (drm_device_is_unplugged(dev)) 670 if (drm_device_is_unplugged(dev))
671 return -ENODEV; 671 return -ENODEV;
672 672
673 if ((nr >= DRM_CORE_IOCTL_COUNT) && 673 if (nr >= DRM_COMMAND_BASE && nr < DRM_COMMAND_END) {
674 ((nr < DRM_COMMAND_BASE) || (nr >= DRM_COMMAND_END))) 674 /* driver ioctl */
675 goto err_i1; 675 if (nr - DRM_COMMAND_BASE >= dev->driver->num_ioctls)
676 if ((nr >= DRM_COMMAND_BASE) && (nr < DRM_COMMAND_END) && 676 goto err_i1;
677 (nr < DRM_COMMAND_BASE + dev->driver->num_ioctls)) {
678 u32 drv_size;
679 ioctl = &dev->driver->ioctls[nr - DRM_COMMAND_BASE]; 677 ioctl = &dev->driver->ioctls[nr - DRM_COMMAND_BASE];
680 drv_size = _IOC_SIZE(ioctl->cmd); 678 } else {
681 usize = asize = _IOC_SIZE(cmd); 679 /* core ioctl */
682 if (drv_size > asize) 680 if (nr >= DRM_CORE_IOCTL_COUNT)
683 asize = drv_size; 681 goto err_i1;
684 cmd = ioctl->cmd;
685 }
686 else if ((nr >= DRM_COMMAND_END) || (nr < DRM_COMMAND_BASE)) {
687 u32 drv_size;
688
689 ioctl = &drm_ioctls[nr]; 682 ioctl = &drm_ioctls[nr];
683 }
690 684
691 drv_size = _IOC_SIZE(ioctl->cmd); 685 drv_size = _IOC_SIZE(ioctl->cmd);
692 usize = asize = _IOC_SIZE(cmd); 686 usize = asize = _IOC_SIZE(cmd);
693 if (drv_size > asize) 687 if (drv_size > asize)
694 asize = drv_size; 688 asize = drv_size;
695 689 cmd = ioctl->cmd;
696 cmd = ioctl->cmd;
697 } else
698 goto err_i1;
699 690
700 DRM_DEBUG("pid=%d, dev=0x%lx, auth=%d, %s\n", 691 DRM_DEBUG("pid=%d, dev=0x%lx, auth=%d, %s\n",
701 task_pid_nr(current), 692 task_pid_nr(current),