]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
USB: serial: fix minor-number allocation
authorJohan Hovold <johan@kernel.org>
Sun, 8 May 2016 18:08:03 +0000 (20:08 +0200)
committerJohan Hovold <johan@kernel.org>
Tue, 10 May 2016 07:40:16 +0000 (09:40 +0200)
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>
drivers/usb/serial/usb-serial.c

index 7ecf4ff86b9a7e26a6cfbff49bba3d698a535de3..4d2b310de55d205c9b0e255abe34cf70369bec94 100644 (file)
@@ -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;