stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: linux-usb@vger.kernel.org
Cc: stable@vger.kernel.org, Johan Hovold <johan@kernel.org>
Subject: [PATCH 8/8] USB: serial: fix minor-number allocation
Date: Sun,  8 May 2016 20:08:03 +0200	[thread overview]
Message-ID: <1462730883-9025-9-git-send-email-johan@kernel.org> (raw)
In-Reply-To: <1462730883-9025-1-git-send-email-johan@kernel.org>

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>
---
 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


  parent reply	other threads:[~2016-05-08 18:08 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-08 18:07 [PATCH 0/8] USB: serial: fix interface URB leaks and use-after-free Johan Hovold
2016-05-08 18:07 ` [PATCH 1/8] USB: serial: io_edgeport: fix memory leaks in attach error path Johan Hovold
2016-05-08 18:07 ` [PATCH 2/8] USB: serial: io_edgeport: fix memory leaks in probe " Johan Hovold
2016-05-08 18:07 ` [PATCH 3/8] USB: serial: keyspan: fix use-after-free " Johan Hovold
2016-05-08 18:07 ` [PATCH 4/8] USB: serial: keyspan: fix URB unlink Johan Hovold
2016-05-08 18:08 ` [PATCH 5/8] USB: serial: keyspan: fix debug and error messages Johan Hovold
2016-05-08 18:08 ` [PATCH 6/8] USB: serial: mxuport: fix use-after-free in probe error path Johan Hovold
2016-05-08 18:08 ` [PATCH 7/8] USB: serial: quatech2: " Johan Hovold
2016-05-08 18:08 ` Johan Hovold [this message]
2016-05-09  5:26   ` [PATCH 8/8] USB: serial: fix minor-number allocation Greg KH
2016-05-10  7:45     ` Johan Hovold

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1462730883-9025-9-git-send-email-johan@kernel.org \
    --to=johan@kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).