提交 c6edc42f 编写于 作者: H Hillf Danton 提交者: Greg Kroah-Hartman

uio: fix allocating minor id for uio device

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: NHillf Danton <dhillf@gmail.com>
Signed-off-by: NHans J. Koch <hjk@hansjkoch.de>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 f0c554fd
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册