Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1532272 > unrolled thread
| Started by | Pan Bian <bianpan2016@163.com> |
|---|---|
| First post | 2016-11-29 14:20 +0100 |
| Last post | 2016-11-29 16:40 +0100 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH 1/1] usb: abort on exception path Pan Bian <bianpan2016@163.com> - 2016-11-29 14:20 +0100
Re: [PATCH 1/1] usb: abort on exception path Johan Hovold <johan@kernel.org> - 2016-11-29 16:40 +0100
| From | Pan Bian <bianpan2016@163.com> |
|---|---|
| Date | 2016-11-29 14:20 +0100 |
| Subject | [PATCH 1/1] usb: abort on exception path |
| Message-ID | <sIQue-v5-7@gated-at.bofh.it> |
Function klsi_105_open() calls usb_control_msg() 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 exit;" when the call
to usb_control_msg() fails.
Signed-off-by: Pan Bian <bianpan2016@163.com>
---
drivers/usb/serial/kl5kusb105.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c
index fc5d3a7..068919f 100644
--- a/drivers/usb/serial/kl5kusb105.c
+++ b/drivers/usb/serial/kl5kusb105.c
@@ -311,6 +311,7 @@ static int klsi_105_open(struct tty_struct *tty, struct usb_serial_port *port)
if (rc < 0) {
dev_err(&port->dev, "Enabling read failed (error = %d)\n", rc);
retval = rc;
+ goto exit;
} else
dev_dbg(&port->dev, "%s - enabled reading\n", __func__);
--
1.9.1
[toc] | [next] | [standalone]
| From | Johan Hovold <johan@kernel.org> |
|---|---|
| Date | 2016-11-29 16:40 +0100 |
| Message-ID | <sISFI-1NU-35@gated-at.bofh.it> |
| In reply to | #1532272 |
On Tue, Nov 29, 2016 at 08:53:35PM +0800, Pan Bian wrote:
> Function klsi_105_open() calls usb_control_msg() 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 exit;" when the call
> to usb_control_msg() fails.
>
> Signed-off-by: Pan Bian <bianpan2016@163.com>
Thanks for the patch.
It turns out there were more issues with the error handling in this
function; for example, the URBs submitted by generic_open were never
stopped on failure to read the line status a bit further down.
I fixed that up and rebased your patch on top.
I'll post both patches to the list shortly.
And next time, please include which driver you are changing in the patch
summary and not just the subsystem prefix (e.g. use "USB: serial:
kl5kusb105: ...").
> ---
> drivers/usb/serial/kl5kusb105.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c
> index fc5d3a7..068919f 100644
> --- a/drivers/usb/serial/kl5kusb105.c
> +++ b/drivers/usb/serial/kl5kusb105.c
> @@ -311,6 +311,7 @@ static int klsi_105_open(struct tty_struct *tty, struct usb_serial_port *port)
> if (rc < 0) {
> dev_err(&port->dev, "Enabling read failed (error = %d)\n", rc);
> retval = rc;
> + goto exit;
> } else
> dev_dbg(&port->dev, "%s - enabled reading\n", __func__);
Thanks,
Johan
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web