Skip to contentSkip to conversation

patch "USB: serial: spcp8x5: fix NULL-deref at open" added to usb-linus

PATCH [email protected] 1 participant 1 message Jan 5, 2017

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

USB: serial: spcp8x5: fix NULL-deref at open

to my usb git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git
in the usb-linus branch.

The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.)

The patch will hopefully also be merged in Linus's tree for the next -rc kernel release.

If you have any questions about this process, please let me know.

Quoted 1 line

From cc0909248258f679c4bb4cd315565d40abaf6bc6 Mon Sep 17 00:00:00 2001

From: Johan Hovold <[email protected]>
Date: Tue, 3 Jan 2017 16:40:02 +0100
Subject: USB: serial: spcp8x5: fix NULL-deref at open

Fix NULL-pointer dereference in open() should the device lack the expected endpoints:

Unable to handle kernel NULL pointer dereference at virtual address 00000030

...
PC is at spcp8x5_open+0x30/0xd0 [spcp8x5]

Fixes 619a6f1d1423 ("USB: add usb-serial spcp8x5 driver")
Cc stable <[email protected]>
---
 drivers/usb/serial/spcp8x5.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/usb/serial/spcp8x5.c +14 -0
index ef0dbf0703c5..475e6c31b266 100644
@@ -154,6 +154,19 @@ static int spcp8x5_probe(struct usb_serial *serial,
 	return 0;
 }
 
+static int spcp8x5_attach(struct usb_serial *serial)
+{
+	unsigned char num_ports = serial->num_ports;
+
+	if (serial->num_bulk_in < num_ports ||
+			serial->num_bulk_out < num_ports) {
+		dev_err(&serial->interface->dev, "missing endpoints\n");
+		return -ENODEV;
+	}
+
+	return 0;
+}
+
 static int spcp8x5_port_probe(struct usb_serial_port *port)
 {
 	const struct usb_device_id *id = usb_get_serial_data(port->serial);
@@ -477,6 +490,7 @@ static struct usb_serial_driver spcp8x5_device = {
 	.tiocmget		= spcp8x5_tiocmget,
 	.tiocmset		= spcp8x5_tiocmset,
 	.probe			= spcp8x5_probe,
+	.attach			= spcp8x5_attach,
 	.port_probe		= spcp8x5_port_probe,
 	.port_remove		= spcp8x5_port_remove,
 };
Signature · 1 line
2.11.0