Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

USB: serial: keyspan: handle unbound ports

Check for NULL port data in the control URB completion handlers to avoid
dereferencing a NULL pointer in the unlikely case where a port device
isn't bound to a driver (e.g. after an allocation failure on port
probe()).

Fixes: 0ca1268e109a ("USB Serial Keyspan: add support for USA-49WG & USA-28XG")
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable <stable@vger.kernel.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>

+4
+4
drivers/usb/serial/keyspan.c
··· 1058 1058 for (i = 0; i < serial->num_ports; ++i) { 1059 1059 port = serial->port[i]; 1060 1060 p_priv = usb_get_serial_port_data(port); 1061 + if (!p_priv) 1062 + continue; 1061 1063 1062 1064 if (p_priv->resend_cont) { 1063 1065 dev_dbg(&port->dev, "%s - sending setup\n", __func__); ··· 1461 1459 for (i = 0; i < serial->num_ports; ++i) { 1462 1460 port = serial->port[i]; 1463 1461 p_priv = usb_get_serial_port_data(port); 1462 + if (!p_priv) 1463 + continue; 1464 1464 1465 1465 if (p_priv->resend_cont) { 1466 1466 dev_dbg(&port->dev, "%s - sending setup\n", __func__);