summaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorJohan Hovold <johan@kernel.org>2020-07-13 12:55:13 +0200
committerJohan Hovold <johan@kernel.org>2020-07-14 11:47:30 +0200
commitbcbb9d812eead97e1fc01b223c0c5586a4ff08d9 (patch)
treeaaadae9dfb5494b5b4e9931a1b1207bdf3db61da /drivers/usb
parentUSB: serial: drop redundant transfer-buffer casts (diff)
downloadlinux-bcbb9d812eead97e1fc01b223c0c5586a4ff08d9.tar.xz
linux-bcbb9d812eead97e1fc01b223c0c5586a4ff08d9.zip
USB: serial: cp210x: disable interface on errors in open
Try to disable the serial interface in the unlikely event that generic open() fails. Link: https://lore.kernel.org/r/20200713105517.27796-2-johan@kernel.org Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Johan Hovold <johan@kernel.org>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/serial/cp210x.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index a90801ef0055..c01c7863dd1a 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -824,7 +824,16 @@ static int cp210x_open(struct tty_struct *tty, struct usb_serial_port *port)
if (tty)
cp210x_change_speed(tty, port, NULL);
- return usb_serial_generic_open(tty, port);
+ result = usb_serial_generic_open(tty, port);
+ if (result)
+ goto err_disable;
+
+ return 0;
+
+err_disable:
+ cp210x_write_u16_reg(port, CP210X_IFC_ENABLE, UART_DISABLE);
+
+ return result;
}
static void cp210x_close(struct usb_serial_port *port)