summaryrefslogtreecommitdiff
path: root/drivers/uio/uio.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-05-19 18:24:11 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2011-05-19 18:24:11 -0700
commit39ab05c8e0b519ff0a04a869f065746e6e8c3d95 (patch)
treee73f0ba74c4ea7a80dff9b2dd9445a3a74190e28 /drivers/uio/uio.c
parent1477fcc290b3d5c2614bde98bf3b1154c538860d (diff)
parentc42d2237143fcf35cff642cefe2bcf7786aae312 (diff)
Merge branch 'driver-core-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6
* 'driver-core-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6: (44 commits) debugfs: Silence DEBUG_STRICT_USER_COPY_CHECKS=y warning sysfs: remove "last sysfs file:" line from the oops messages drivers/base/memory.c: fix warning due to "memory hotplug: Speed up add/remove when blocks are larger than PAGES_PER_SECTION" memory hotplug: Speed up add/remove when blocks are larger than PAGES_PER_SECTION SYSFS: Fix erroneous comments for sysfs_update_group(). driver core: remove the driver-model structures from the documentation driver core: Add the device driver-model structures to kerneldoc Translated Documentation/email-clients.txt RAW driver: Remove call to kobject_put(). reboot: disable usermodehelper to prevent fs access efivars: prevent oops on unload when efi is not enabled Allow setting of number of raw devices as a module parameter Introduce CONFIG_GOOGLE_FIRMWARE driver: Google Memory Console driver: Google EFI SMI x86: Better comments for get_bios_ebda() x86: get_bios_ebda_length() misc: fix ti-st build issues params.c: Use new strtobool function to process boolean inputs debugfs: move to new strtobool ... Fix up trivial conflicts in fs/debugfs/file.c due to the same patch being applied twice, and an unrelated cleanup nearby.
Diffstat (limited to 'drivers/uio/uio.c')
-rw-r--r--drivers/uio/uio.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index 51fe1795d5a..d2efe823c20 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -381,7 +381,13 @@ static int uio_get_minor(struct uio_device *idev)
retval = -ENOMEM;
goto exit;
}
- idev->minor = id & MAX_ID_MASK;
+ if (id < UIO_MAX_DEVICES) {
+ idev->minor = id;
+ } else {
+ dev_err(idev->dev, "too many uio devices\n");
+ retval = -EINVAL;
+ idr_remove(&uio_idr, id);
+ }
exit:
mutex_unlock(&minor_lock);
return retval;
@@ -587,14 +593,12 @@ static ssize_t uio_write(struct file *filep, const char __user *buf,
static int uio_find_mem_index(struct vm_area_struct *vma)
{
- int mi;
struct uio_device *idev = vma->vm_private_data;
- for (mi = 0; mi < MAX_UIO_MAPS; mi++) {
- if (idev->info->mem[mi].size == 0)
+ if (vma->vm_pgoff < MAX_UIO_MAPS) {
+ if (idev->info->mem[vma->vm_pgoff].size == 0)
return -1;
- if (vma->vm_pgoff == mi)
- return mi;
+ return (int)vma->vm_pgoff;
}
return -1;
}