Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 194e958c authored by Johan Hovold's avatar Johan Hovold
Browse files

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: default avatarJohan Hovold <johan@kernel.org>
Acked-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 028c49f5
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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;