linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Johan Hovold <johan@kernel.org>
Subject: [PATCH 3.18 23/39] USB: serial: ark3116: fix open error handling
Date: Thu, 11 May 2017 15:02:58 +0200	[thread overview]
Message-ID: <20170511130243.088857339@linuxfoundation.org> (raw)
In-Reply-To: <20170511130238.045434679@linuxfoundation.org>

3.18-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Johan Hovold <johan@kernel.org>

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: f4c1e8d597d1 ("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>

---
 drivers/usb/serial/ark3116.c |   25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

--- a/drivers/usb/serial/ark3116.c
+++ b/drivers/usb/serial/ark3116.c
@@ -366,23 +366,29 @@ static int ark3116_open(struct tty_struc
 		dev_dbg(&port->dev,
 			"%s - usb_serial_generic_open failed: %d\n",
 			__func__, result);
-		goto err_out;
+		goto err_free;
 	}
 
 	/* remove any data still left: also clears error state */
 	ark3116_read_reg(serial, UART_RX, buf);
 
 	/* read modem status */
-	priv->msr = ark3116_read_reg(serial, UART_MSR, buf);
+	result = ark3116_read_reg(serial, UART_MSR, buf);
+	if (result < 0)
+		goto err_close;
+	priv->msr = *buf;
+
 	/* read line status */
-	priv->lsr = ark3116_read_reg(serial, UART_LSR, buf);
+	result = ark3116_read_reg(serial, UART_LSR, buf);
+	if (result < 0)
+		goto err_close;
+	priv->lsr = *buf;
 
 	result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
 	if (result) {
 		dev_err(&port->dev, "submit irq_in urb failed %d\n",
 			result);
-		ark3116_close(port);
-		goto err_out;
+		goto err_close;
 	}
 
 	/* activate interrupts */
@@ -395,8 +401,15 @@ static int ark3116_open(struct tty_struc
 	if (tty)
 		ark3116_set_termios(tty, port, NULL);
 
-err_out:
 	kfree(buf);
+
+	return 0;
+
+err_close:
+	usb_serial_generic_close(port);
+err_free:
+	kfree(buf);
+
 	return result;
 }
 

  parent reply	other threads:[~2017-05-11 13:07 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-11 13:02 [PATCH 3.18 00/39] 3.18.53-stable review Greg Kroah-Hartman
2017-05-11 13:02 ` [PATCH 3.18 01/39] 9p: fix a potential acl leak Greg Kroah-Hartman
2017-05-11 13:02 ` [PATCH 3.18 02/39] tty: remove platform_sysrq_reset_seq Greg Kroah-Hartman
2017-05-11 13:02 ` [PATCH 3.18 03/39] mtd: cfi: reduce stack size Greg Kroah-Hartman
2017-05-11 13:02 ` [PATCH 3.18 04/39] ARM: 8452/3: PJ4: make coprocessor access sequences buildable in Thumb2 mode Greg Kroah-Hartman
2017-05-11 13:02 ` [PATCH 3.18 05/39] cpupower: Fix turbo frequency reporting for pre-Sandy Bridge cores Greg Kroah-Hartman
2017-05-11 13:02 ` [PATCH 3.18 06/39] powerpc/powernv: Fix opal_exit tracepoint opcode Greg Kroah-Hartman
2017-05-11 13:02 ` [PATCH 3.18 07/39] power: supply: bq24190_charger: Fix irq trigger to IRQF_TRIGGER_FALLING Greg Kroah-Hartman
2017-05-11 13:02 ` [PATCH 3.18 08/39] power: supply: bq24190_charger: Call set_mode_host() on pm_resume() Greg Kroah-Hartman
2017-05-11 13:02 ` [PATCH 3.18 09/39] ARM: OMAP5 / DRA7: Fix HYP mode boot for thumb2 build Greg Kroah-Hartman
2017-05-11 13:02 ` [PATCH 3.18 10/39] mwifiex: debugfs: Fix (sometimes) off-by-1 SSID print Greg Kroah-Hartman
2017-05-11 13:02 ` [PATCH 3.18 11/39] mwifiex: Avoid skipping WEP key deletion for AP Greg Kroah-Hartman
2017-05-11 13:02 ` [PATCH 3.18 13/39] kprobes/x86: Fix kernel panic when certain exception-handling addresses are probed Greg Kroah-Hartman
2017-05-11 13:02 ` [PATCH 3.18 14/39] x86/platform/intel-mid: Correct MSI IRQ line for watchdog device Greg Kroah-Hartman
2017-05-11 13:02 ` [PATCH 3.18 16/39] usb: host: ehci-exynos: Decrese node refcount on exynos_ehci_get_phy() error paths Greg Kroah-Hartman
2017-05-11 13:02 ` [PATCH 3.18 17/39] usb: host: ohci-exynos: " Greg Kroah-Hartman
2017-05-11 13:02 ` [PATCH 3.18 18/39] USB: serial: keyspan_pda: fix receive sanity checks Greg Kroah-Hartman
2017-05-11 13:02 ` [PATCH 3.18 19/39] USB: serial: digi_acceleport: fix incomplete rx sanity check Greg Kroah-Hartman
2017-05-11 13:02 ` [PATCH 3.18 20/39] USB: serial: ssu100: fix control-message error handling Greg Kroah-Hartman
2017-05-11 13:02 ` [PATCH 3.18 21/39] USB: serial: io_edgeport: fix epic-descriptor handling Greg Kroah-Hartman
2017-05-11 13:02 ` [PATCH 3.18 22/39] USB: serial: ti_usb_3410_5052: fix control-message error handling Greg Kroah-Hartman
2017-05-11 13:02 ` Greg Kroah-Hartman [this message]
2017-05-11 13:02 ` [PATCH 3.18 24/39] USB: serial: ftdi_sio: fix latency-timer " Greg Kroah-Hartman
2017-05-11 13:03 ` [PATCH 3.18 25/39] USB: serial: quatech2: fix control-message " Greg Kroah-Hartman
2017-05-11 13:03 ` [PATCH 3.18 26/39] USB: serial: mct_u232: fix modem-status " Greg Kroah-Hartman
2017-05-11 13:03 ` [PATCH 3.18 27/39] USB: serial: io_edgeport: fix descriptor " Greg Kroah-Hartman
2017-05-11 13:03 ` [PATCH 3.18 28/39] USB: serial: sierra: fix bogus alternate-setting assumption Greg Kroah-Hartman
2017-05-11 13:03 ` [PATCH 3.18 29/39] scsi: scsi_dh_emc: return success in clariion_std_inquiry() Greg Kroah-Hartman
2017-05-11 13:03 ` [PATCH 3.18 30/39] brcmfmac: Ensure pointer correctly set if skb data location changes Greg Kroah-Hartman
2017-05-11 13:03 ` [PATCH 3.18 31/39] brcmfmac: Make skb header writable before use Greg Kroah-Hartman
2017-05-11 13:03 ` [PATCH 3.18 32/39] staging: emxx_udc: remove incorrect __init annotations Greg Kroah-Hartman
2017-05-11 13:03 ` [PATCH 3.18 33/39] tcp: do not underestimate skb->truesize in tcp_trim_head() Greg Kroah-Hartman
2017-05-11 13:03 ` [PATCH 3.18 34/39] ipv4, ipv6: ensure raw socket message is big enough to hold an IP header Greg Kroah-Hartman
2017-05-11 13:03 ` [PATCH 3.18 35/39] ipv6: initialize route null entry in addrconf_init() Greg Kroah-Hartman
2017-05-11 13:03 ` [PATCH 3.18 36/39] ipv6: reorder ip6_route_dev_notifier after ipv6_dev_notf Greg Kroah-Hartman
2017-05-11 13:03 ` [PATCH 3.18 37/39] tcp: fix wraparound issue in tcp_lp Greg Kroah-Hartman
2017-05-11 13:03 ` [PATCH 3.18 38/39] f2fs: sanity check segment count Greg Kroah-Hartman
2017-05-11 21:16 ` [PATCH 3.18 00/39] 3.18.53-stable review Guenter Roeck
2017-05-11 21:31   ` Matthijs van Duin
2017-05-11 21:46     ` Tony Lindgren
2017-05-12  9:37       ` Greg Kroah-Hartman
2017-05-12 10:15         ` Arnd Bergmann
2017-05-12 10:44           ` Greg Kroah-Hartman
2017-05-12 15:23 ` Shuah Khan
2017-05-12 19:47 ` Guenter Roeck
2017-05-14 10:56   ` Greg Kroah-Hartman
2017-05-14 14:02     ` Guenter Roeck
2017-05-14 20:58       ` Greg Kroah-Hartman
2017-05-14 23:38         ` Guenter Roeck
2017-05-15  6:17           ` Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170511130243.088857339@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=johan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).