diff options
Diffstat (limited to 'drivers/uio/uio.c')
-rw-r--r-- | drivers/uio/uio.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c index 51fe1795d5a8..d2efe823c20d 100644 --- a/drivers/uio/uio.c +++ b/drivers/uio/uio.c | |||
@@ -381,7 +381,13 @@ static int uio_get_minor(struct uio_device *idev) | |||
381 | retval = -ENOMEM; | 381 | retval = -ENOMEM; |
382 | goto exit; | 382 | goto exit; |
383 | } | 383 | } |
384 | idev->minor = id & MAX_ID_MASK; | 384 | if (id < UIO_MAX_DEVICES) { |
385 | idev->minor = id; | ||
386 | } else { | ||
387 | dev_err(idev->dev, "too many uio devices\n"); | ||
388 | retval = -EINVAL; | ||
389 | idr_remove(&uio_idr, id); | ||
390 | } | ||
385 | exit: | 391 | exit: |
386 | mutex_unlock(&minor_lock); | 392 | mutex_unlock(&minor_lock); |
387 | return retval; | 393 | return retval; |
@@ -587,14 +593,12 @@ static ssize_t uio_write(struct file *filep, const char __user *buf, | |||
587 | 593 | ||
588 | static int uio_find_mem_index(struct vm_area_struct *vma) | 594 | static int uio_find_mem_index(struct vm_area_struct *vma) |
589 | { | 595 | { |
590 | int mi; | ||
591 | struct uio_device *idev = vma->vm_private_data; | 596 | struct uio_device *idev = vma->vm_private_data; |
592 | 597 | ||
593 | for (mi = 0; mi < MAX_UIO_MAPS; mi++) { | 598 | if (vma->vm_pgoff < MAX_UIO_MAPS) { |
594 | if (idev->info->mem[mi].size == 0) | 599 | if (idev->info->mem[vma->vm_pgoff].size == 0) |
595 | return -1; | 600 | return -1; |
596 | if (vma->vm_pgoff == mi) | 601 | return (int)vma->vm_pgoff; |
597 | return mi; | ||
598 | } | 602 | } |
599 | return -1; | 603 | return -1; |
600 | } | 604 | } |