aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorJohan Hovold <johan@kernel.org>2017-01-03 10:39:52 -0500
committerJohan Hovold <johan@kernel.org>2017-01-04 04:37:19 -0500
commit75dd211e773afcbc264677b0749d1cf7d937ab2d (patch)
tree78c903f206950fd0f2573e95ac9e6c98e1f89e01 /drivers/usb
parent91a1ff4d53c5184d383d0baeeaeab6f9736f2ff3 (diff)
USB: serial: mos7720: fix parport use-after-free on probe errors
Do not submit the interrupt URB until after the parport has been successfully registered to avoid another use-after-free in the completion handler when accessing the freed parport private data in case of a racing completion. Fixes: b69578df7e98 ("USB: usbserial: mos7720: add support for parallel port on moschip 7715") Cc: stable <stable@vger.kernel.org> Signed-off-by: Johan Hovold <johan@kernel.org>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/serial/mos7720.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
index 9170ae856b34..e494821ae528 100644
--- a/drivers/usb/serial/mos7720.c
+++ b/drivers/usb/serial/mos7720.c
@@ -1952,22 +1952,20 @@ static int mos7720_startup(struct usb_serial *serial)
1952 usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 1952 usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
1953 (__u8)0x03, 0x00, 0x01, 0x00, NULL, 0x00, 5000); 1953 (__u8)0x03, 0x00, 0x01, 0x00, NULL, 0x00, 5000);
1954 1954
1955 /* start the interrupt urb */
1956 ret_val = usb_submit_urb(serial->port[0]->interrupt_in_urb, GFP_KERNEL);
1957 if (ret_val)
1958 dev_err(&dev->dev,
1959 "%s - Error %d submitting control urb\n",
1960 __func__, ret_val);
1961
1962#ifdef CONFIG_USB_SERIAL_MOS7715_PARPORT 1955#ifdef CONFIG_USB_SERIAL_MOS7715_PARPORT
1963 if (product == MOSCHIP_DEVICE_ID_7715) { 1956 if (product == MOSCHIP_DEVICE_ID_7715) {
1964 ret_val = mos7715_parport_init(serial); 1957 ret_val = mos7715_parport_init(serial);
1965 if (ret_val < 0) { 1958 if (ret_val < 0)
1966 usb_kill_urb(serial->port[0]->interrupt_in_urb);
1967 return ret_val; 1959 return ret_val;
1968 }
1969 } 1960 }
1970#endif 1961#endif
1962 /* start the interrupt urb */
1963 ret_val = usb_submit_urb(serial->port[0]->interrupt_in_urb, GFP_KERNEL);
1964 if (ret_val) {
1965 dev_err(&dev->dev, "failed to submit interrupt urb: %d\n",
1966 ret_val);
1967 }
1968
1971 /* LSR For Port 1 */ 1969 /* LSR For Port 1 */
1972 read_mos_reg(serial, 0, MOS7720_LSR, &data); 1970 read_mos_reg(serial, 0, MOS7720_LSR, &data);
1973 dev_dbg(&dev->dev, "LSR:%x\n", data); 1971 dev_dbg(&dev->dev, "LSR:%x\n", data);