mirror of
https://github.com/joel16/android_kernel_sony_msm8994.git
synced 2024-11-27 06:01:12 +00:00
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: Hillf Danton <dhillf@gmail.com> Signed-off-by: Hans J. Koch <hjk@hansjkoch.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
f0c554fddd
commit
c6edc42fe1
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user