Commit 3c3dd1e0 authored by Pan Bian's avatar Pan Bian Committed by Johan Hovold

USB: serial: kl5kusb105: abort on open exception path

Function klsi_105_open() calls usb_control_msg() (to "enable read") and
checks its return value. When the return value is unexpected, it only
assigns the error code to the return variable retval, but does not
terminate the exception path. This patch fixes the bug by inserting
"goto err_generic_close;" when the call to usb_control_msg() fails.

Fixes: 1da177e4 ("Linux-2.6.12-rc2")
Signed-off-by: default avatarPan Bian <bianpan2016@163.com>
[johan: rebase on prerequisite fix and amend commit message]
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
parent 6774d5f5
...@@ -311,6 +311,7 @@ static int klsi_105_open(struct tty_struct *tty, struct usb_serial_port *port) ...@@ -311,6 +311,7 @@ static int klsi_105_open(struct tty_struct *tty, struct usb_serial_port *port)
if (rc < 0) { if (rc < 0) {
dev_err(&port->dev, "Enabling read failed (error = %d)\n", rc); dev_err(&port->dev, "Enabling read failed (error = %d)\n", rc);
retval = rc; retval = rc;
goto err_generic_close;
} else } else
dev_dbg(&port->dev, "%s - enabled reading\n", __func__); dev_dbg(&port->dev, "%s - enabled reading\n", __func__);
...@@ -337,6 +338,7 @@ static int klsi_105_open(struct tty_struct *tty, struct usb_serial_port *port) ...@@ -337,6 +338,7 @@ static int klsi_105_open(struct tty_struct *tty, struct usb_serial_port *port)
0, /* index */ 0, /* index */
NULL, 0, NULL, 0,
KLSI_TIMEOUT); KLSI_TIMEOUT);
err_generic_close:
usb_serial_generic_close(port); usb_serial_generic_close(port);
err_free_cfg: err_free_cfg:
kfree(cfg); kfree(cfg);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment