From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf0-f66.google.com ([209.85.215.66]:33818 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750926AbcEHSIT (ORCPT ); Sun, 8 May 2016 14:08:19 -0400 From: Johan Hovold To: linux-usb@vger.kernel.org Cc: stable@vger.kernel.org, Johan Hovold Subject: [PATCH 8/8] USB: serial: fix minor-number allocation Date: Sun, 8 May 2016 20:08:03 +0200 Message-Id: <1462730883-9025-9-git-send-email-johan@kernel.org> In-Reply-To: <1462730883-9025-1-git-send-email-johan@kernel.org> References: <1462730883-9025-1-git-send-email-johan@kernel.org> Sender: stable-owner@vger.kernel.org List-ID: 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 --- drivers/usb/serial/usb-serial.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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; -- 2.7.3