diff options
-rw-r--r-- | drivers/usb/serial/ark3116.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c index 7812052dc700..754fc3e41005 100644 --- a/drivers/usb/serial/ark3116.c +++ b/drivers/usb/serial/ark3116.c | |||
@@ -373,23 +373,29 @@ static int ark3116_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
373 | dev_dbg(&port->dev, | 373 | dev_dbg(&port->dev, |
374 | "%s - usb_serial_generic_open failed: %d\n", | 374 | "%s - usb_serial_generic_open failed: %d\n", |
375 | __func__, result); | 375 | __func__, result); |
376 | goto err_out; | 376 | goto err_free; |
377 | } | 377 | } |
378 | 378 | ||
379 | /* remove any data still left: also clears error state */ | 379 | /* remove any data still left: also clears error state */ |
380 | ark3116_read_reg(serial, UART_RX, buf); | 380 | ark3116_read_reg(serial, UART_RX, buf); |
381 | 381 | ||
382 | /* read modem status */ | 382 | /* 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 | |||
384 | /* read line status */ | 388 | /* 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; | ||
386 | 393 | ||
387 | result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); | 394 | result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); |
388 | if (result) { | 395 | if (result) { |
389 | dev_err(&port->dev, "submit irq_in urb failed %d\n", | 396 | dev_err(&port->dev, "submit irq_in urb failed %d\n", |
390 | result); | 397 | result); |
391 | ark3116_close(port); | 398 | goto err_close; |
392 | goto err_out; | ||
393 | } | 399 | } |
394 | 400 | ||
395 | /* activate interrupts */ | 401 | /* activate interrupts */ |
@@ -402,8 +408,15 @@ static int ark3116_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
402 | if (tty) | 408 | if (tty) |
403 | ark3116_set_termios(tty, port, NULL); | 409 | ark3116_set_termios(tty, port, NULL); |
404 | 410 | ||
405 | err_out: | ||
406 | kfree(buf); | 411 | kfree(buf); |
412 | |||
413 | return 0; | ||
414 | |||
415 | err_close: | ||
416 | usb_serial_generic_close(port); | ||
417 | err_free: | ||
418 | kfree(buf); | ||
419 | |||
407 | return result; | 420 | return result; |
408 | } | 421 | } |
409 | 422 | ||