Skip to content

Commit

Permalink
uio: fix allocating minor id for uio device
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Hillf Danton authored and Greg Kroah-Hartman committed Apr 19, 2011
1 parent f0c554f commit c6edc42
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion drivers/uio/uio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit c6edc42

Please sign in to comment.