Skip to content

Commit 5890ca8

Browse files
jhovoldgregkh
authored andcommitted
USB: serial: ark3116: fix open error handling
commit b631433b175f1002a31020e09bbfc2e5caecf290 upstream. Fix open error handling which failed to detect errors when reading the MSR and LSR registers, something which could lead to the shadow registers being initialised from errnos. Note that calling the generic close implementation is sufficient in the error paths as the interrupt urb has not yet been submitted and the register updates have not been made. Fixes: f4c1e8d ("USB: ark3116: Make existing functions 16450-aware and add close and release functions.") Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent fb4d672 commit 5890ca8

1 file changed

Lines changed: 19 additions & 6 deletions

File tree

drivers/usb/serial/ark3116.c

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -373,23 +373,29 @@ static int ark3116_open(struct tty_struct *tty, struct usb_serial_port *port)
373373
dev_dbg(&port->dev,
374374
"%s - usb_serial_generic_open failed: %d\n",
375375
__func__, result);
376-
goto err_out;
376+
goto err_free;
377377
}
378378

379379
/* remove any data still left: also clears error state */
380380
ark3116_read_reg(serial, UART_RX, buf);
381381

382382
/* read modem status */
383-
priv->msr = ark3116_read_reg(serial, UART_MSR, buf);
383+
result = ark3116_read_reg(serial, UART_MSR, buf);
384+
if (result < 0)
385+
goto err_close;
386+
priv->msr = *buf;
387+
384388
/* read line status */
385-
priv->lsr = ark3116_read_reg(serial, UART_LSR, buf);
389+
result = ark3116_read_reg(serial, UART_LSR, buf);
390+
if (result < 0)
391+
goto err_close;
392+
priv->lsr = *buf;
386393

387394
result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
388395
if (result) {
389396
dev_err(&port->dev, "submit irq_in urb failed %d\n",
390397
result);
391-
ark3116_close(port);
392-
goto err_out;
398+
goto err_close;
393399
}
394400

395401
/* activate interrupts */
@@ -402,8 +408,15 @@ static int ark3116_open(struct tty_struct *tty, struct usb_serial_port *port)
402408
if (tty)
403409
ark3116_set_termios(tty, port, NULL);
404410

405-
err_out:
406411
kfree(buf);
412+
413+
return 0;
414+
415+
err_close:
416+
usb_serial_generic_close(port);
417+
err_free:
418+
kfree(buf);
419+
407420
return result;
408421
}
409422

0 commit comments

Comments
 (0)