[PATCH] uio: fix allocating minor id for uio device

From: zhdxzx
Date: Sun Mar 27 2011 - 03:44:58 EST


The number of uio devices that could be used should be less than UIO_MAX_DEVICES by design,
and this work guards any cases in which id more than UIO_MAX_DEVICES is utilized.

Signed-off-by: Hillf Danton <dhillf@xxxxxxxxx>
---

--- a/drivers/uio/uio.c 2011-01-05 08:50:20.000000000 +0800
+++ b/drivers/uio/uio.c 2011-03-27 15:05:26.000000000 +0800
@@ -381,7 +381,13 @@ static int uio_get_minor(struct uio_devi
retval = -ENOMEM;
goto exit;
}
- idev->minor = id & MAX_ID_MASK;
+ if (id < UIO_MAX_DEVICES)
+ idev->minor = id;
+ else {
+ printk(KERN_ERR "uio: too many uio devices\n");
+ retval = -EINVAL;
+ idr_remove(&uio_idr, id);
+ }
exit:
mutex_unlock(&minor_lock);
return retval;
㈤旃??迆??瑬+-遍荻w疄藳笔鈓閎烄dz罐?韰骅w*jg?秹殠娸/侁鋤罐枈?娹櫒璀??摺玜囤瓽珴閔?鎗:+v墾妛鑶佶>W毐贽i踑xPj豰稛? -?+凒d歘