summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hovold <johan@kernel.org>2016-05-08 20:08:03 +0200
committerJohan Hovold <johan@kernel.org>2016-05-10 09:40:16 +0200
commit194e958c5c3bf4fa0805b0653fe2d0428d3791ff (patch)
tree5cef6d57eb949248eeefadd3f7672e1e96c09c44
parent028c49f5e02a257c94129cd815f7c8485f51d4ef (diff)
downloadlinux-194e958c5c3bf4fa0805b0653fe2d0428d3791ff.tar.gz
linux-194e958c5c3bf4fa0805b0653fe2d0428d3791ff.tar.bz2
linux-194e958c5c3bf4fa0805b0653fe2d0428d3791ff.zip
USB: serial: fix minor-number allocation
Due to a missing upper bound, invalid minor numbers could be assigned to ports. Such devices would later fail to register, but let's catch this early as intended and avoid having devices with only a subset of their ports registered (potentially the empty set). Signed-off-by: Johan Hovold <johan@kernel.org> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/usb/serial/usb-serial.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 7ecf4ff86b9a..4d2b310de55d 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -96,7 +96,8 @@ static int allocate_minors(struct usb_serial *serial, int num_ports)
mutex_lock(&table_lock);
for (i = 0; i < num_ports; ++i) {
port = serial->port[i];
- minor = idr_alloc(&serial_minors, port, 0, 0, GFP_KERNEL);
+ minor = idr_alloc(&serial_minors, port, 0,
+ USB_SERIAL_TTY_MINORS, GFP_KERNEL);
if (minor < 0)
goto error;
port->minor = minor;