From: "Levin, Alexander (Sasha Levin)" <alexander.levin@verizon.com>
To: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Cc: Johan Hovold <johan@kernel.org>,
"Levin, Alexander (Sasha Levin)" <alexander.levin@verizon.com>
Subject: [PATCH review for 3.18 14/30] USB: serial: mos7840: fix control-message error handling
Date: Wed, 20 Sep 2017 04:45:53 +0000 [thread overview]
Message-ID: <20170920044542.7571-14-alexander.levin@verizon.com> (raw)
In-Reply-To: <20170920044542.7571-1-alexander.levin@verizon.com>
From: Johan Hovold <johan@kernel.org>
[ Upstream commit cd8db057e93ddaacbec025b567490555d2bca280 ]
Make sure to detect short transfers when reading a device register.
The modem-status handling had sufficient error checks in place, but move
handling of short transfers into the register accessor function itself
for consistency.
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
drivers/usb/serial/mos7840.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index 0b547d9e2aeb..a0dca81dfaca 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -285,9 +285,15 @@ static int mos7840_get_reg_sync(struct usb_serial_port *port, __u16 reg,
ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), MCS_RDREQ,
MCS_RD_RTYPE, 0, reg, buf, VENDOR_READ_LENGTH,
MOS_WDR_TIMEOUT);
+ if (ret < VENDOR_READ_LENGTH) {
+ if (ret >= 0)
+ ret = -EIO;
+ goto out;
+ }
+
*val = buf[0];
dev_dbg(&port->dev, "%s offset is %x, return val %x\n", __func__, reg, *val);
-
+out:
kfree(buf);
return ret;
}
@@ -353,8 +359,13 @@ static int mos7840_get_uart_reg(struct usb_serial_port *port, __u16 reg,
ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), MCS_RDREQ,
MCS_RD_RTYPE, Wval, reg, buf, VENDOR_READ_LENGTH,
MOS_WDR_TIMEOUT);
+ if (ret < VENDOR_READ_LENGTH) {
+ if (ret >= 0)
+ ret = -EIO;
+ goto out;
+ }
*val = buf[0];
-
+out:
kfree(buf);
return ret;
}
@@ -1518,10 +1529,10 @@ static int mos7840_tiocmget(struct tty_struct *tty)
return -ENODEV;
status = mos7840_get_uart_reg(port, MODEM_STATUS_REGISTER, &msr);
- if (status != 1)
+ if (status < 0)
return -EIO;
status = mos7840_get_uart_reg(port, MODEM_CONTROL_REGISTER, &mcr);
- if (status != 1)
+ if (status < 0)
return -EIO;
result = ((mcr & MCR_DTR) ? TIOCM_DTR : 0)
| ((mcr & MCR_RTS) ? TIOCM_RTS : 0)
--
2.11.0
next prev parent reply other threads:[~2017-09-20 4:50 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-20 4:45 [PATCH review for 3.18 01/30] drm: bridge: add DT bindings for TI ths8135 Levin, Alexander (Sasha Levin)
2017-09-20 4:45 ` [PATCH review for 3.18 02/30] RDS: RDMA: Fix the composite message user notification Levin, Alexander (Sasha Levin)
2017-09-20 4:45 ` [PATCH review for 3.18 03/30] MIPS: Ensure bss section ends on a long-aligned address Levin, Alexander (Sasha Levin)
2017-09-20 4:45 ` [PATCH review for 3.18 04/30] MIPS: kexec: Do not reserve invalid crashkernel memory on boot Levin, Alexander (Sasha Levin)
2017-09-20 4:45 ` [PATCH review for 3.18 07/30] hwmon: (gl520sm) Fix overflows and crash seen when writing into limit attributes Levin, Alexander (Sasha Levin)
2017-09-20 4:45 ` [PATCH review for 3.18 06/30] clk: wm831x: fix usleep_range with bad range Levin, Alexander (Sasha Levin)
2017-09-20 4:45 ` [PATCH review for 3.18 05/30] sh_eth: use correct name for ECMR_MPDE bit Levin, Alexander (Sasha Levin)
2017-09-20 4:45 ` [PATCH review for 3.18 10/30] IB/ipoib: Fix deadlock over vlan_mutex Levin, Alexander (Sasha Levin)
2017-09-20 4:45 ` [PATCH review for 3.18 11/30] IB/ipoib: rtnl_unlock can not come after free_netdev Levin, Alexander (Sasha Levin)
2017-09-20 4:45 ` [PATCH review for 3.18 09/30] tty: goldfish: Fix a parameter of a call to free_irq Levin, Alexander (Sasha Levin)
2017-09-20 4:45 ` [PATCH review for 3.18 12/30] IB/ipoib: Replace list_del of the neigh->list with list_del_init Levin, Alexander (Sasha Levin)
2017-09-20 4:45 ` [PATCH review for 3.18 08/30] ARM: 8635/1: nommu: allow enabling REMAP_VECTORS_TO_RAM Levin, Alexander (Sasha Levin)
2017-09-20 4:45 ` [PATCH review for 3.18 13/30] USB: serial: mos7720: fix control-message error handling Levin, Alexander (Sasha Levin)
2017-09-20 4:45 ` [PATCH review for 3.18 15/30] pinctrl: mvebu: Use seq_puts() in mvebu_pinconf_group_dbg_show() Levin, Alexander (Sasha Levin)
2017-09-20 4:45 ` [PATCH review for 3.18 16/30] partitions/efi: Fix integer overflow in GPT size calculation Levin, Alexander (Sasha Levin)
2017-09-20 4:45 ` Levin, Alexander (Sasha Levin) [this message]
2017-09-20 4:45 ` [PATCH review for 3.18 20/30] team: fix memory leaks Levin, Alexander (Sasha Levin)
2017-09-20 4:45 ` [PATCH review for 3.18 19/30] net/packet: check length in getsockopt() called with PACKET_HDRLEN Levin, Alexander (Sasha Levin)
2017-09-20 4:45 ` [PATCH review for 3.18 17/30] audit: log 32-bit socketcalls Levin, Alexander (Sasha Levin)
2017-09-20 4:45 ` [PATCH review for 3.18 18/30] net: core: Prevent from dereferencing null pointer when releasing SKB Levin, Alexander (Sasha Levin)
2017-09-20 4:45 ` [PATCH review for 3.18 24/30] [media] exynos-gsc: Do not swap cb/cr for semi planar formats Levin, Alexander (Sasha Levin)
2017-09-20 4:45 ` [PATCH review for 3.18 23/30] netfilter: invoke synchronize_rcu after set the _hook_ to NULL Levin, Alexander (Sasha Levin)
2017-09-20 4:45 ` [PATCH review for 3.18 21/30] usb: plusb: Add support for PL-27A1 Levin, Alexander (Sasha Levin)
2017-09-20 4:45 ` [PATCH review for 3.18 22/30] mmc: sdio: fix alignment issue in struct sdio_func Levin, Alexander (Sasha Levin)
2017-09-20 4:45 ` [PATCH review for 3.18 25/30] netfilter: nfnl_cthelper: fix incorrect helper->expect_class_max Levin, Alexander (Sasha Levin)
2017-09-20 4:45 ` [PATCH review for 3.18 28/30] md/raid10: submit bio directly to replacement disk Levin, Alexander (Sasha Levin)
2017-09-20 4:45 ` [PATCH review for 3.18 27/30] rds: ib: add error handle Levin, Alexander (Sasha Levin)
2017-09-20 4:45 ` [PATCH review for 3.18 26/30] parisc: perf: Fix potential NULL pointer dereference Levin, Alexander (Sasha Levin)
2017-09-20 4:45 ` [PATCH review for 3.18 30/30] libata: transport: Remove circular dependency at free time Levin, Alexander (Sasha Levin)
2017-09-20 4:45 ` [PATCH review for 3.18 29/30] xfs: remove kmem_zalloc_greedy Levin, Alexander (Sasha Levin)
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=20170920044542.7571-14-alexander.levin@verizon.com \
--to=alexander.levin@verizon.com \
--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
all inboxes | Powered by JetHome®