bug from Linux kernel list caught by checker
authorDave Airlie <airlied@linux.ie>
Wed, 21 Apr 2004 12:18:42 +0000 (12:18 +0000)
committerDave Airlie <airlied@linux.ie>
Wed, 21 Apr 2004 12:18:42 +0000 (12:18 +0000)
linux-core/i810_dma.c
linux/i810_dma.c

index 651b080..308d28e 100644 (file)
@@ -1275,12 +1275,14 @@ int i810_dma_mc(struct inode *inode, struct file *filp,
        if (copy_from_user(&mc, (drm_i810_mc_t *)arg, sizeof(mc)))
                return -EFAULT;
 
-
        if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
                DRM_ERROR("i810_dma_mc called without lock held\n");
                return -EINVAL;
        }
 
+       if (mc.idx >= dma->buf_count || mc.idx < 0)
+               return -EINVAL;
+
        i810_dma_dispatch_mc(dev, dma->buflist[mc.idx], mc.used,
                mc.last_render );
 
index 651b080..308d28e 100644 (file)
@@ -1275,12 +1275,14 @@ int i810_dma_mc(struct inode *inode, struct file *filp,
        if (copy_from_user(&mc, (drm_i810_mc_t *)arg, sizeof(mc)))
                return -EFAULT;
 
-
        if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
                DRM_ERROR("i810_dma_mc called without lock held\n");
                return -EINVAL;
        }
 
+       if (mc.idx >= dma->buf_count || mc.idx < 0)
+               return -EINVAL;
+
        i810_dma_dispatch_mc(dev, dma->buflist[mc.idx], mc.used,
                mc.last_render );