All of lore.kernel.org
 help / color / mirror / Atom feed
* Patch "USB: serial: quatech2: fix control-message error handling" has been added to the 4.9-stable tree
@ 2017-05-09  9:42 gregkh
  0 siblings, 0 replies; only message in thread
From: gregkh @ 2017-05-09  9:42 UTC (permalink / raw)
  To: johan, gregkh; +Cc: stable, stable-commits


This is a note to let you know that I've just added the patch titled

    USB: serial: quatech2: fix control-message error handling

to the 4.9-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     usb-serial-quatech2-fix-control-message-error-handling.patch
and it can be found in the queue-4.9 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.


>From 8c34cb8ddfe808d557b51da983ff10c02793beb2 Mon Sep 17 00:00:00 2001
From: Johan Hovold <johan@kernel.org>
Date: Thu, 12 Jan 2017 14:56:20 +0100
Subject: USB: serial: quatech2: fix control-message error handling

From: Johan Hovold <johan@kernel.org>

commit 8c34cb8ddfe808d557b51da983ff10c02793beb2 upstream.

Make sure to detect short control-message transfers when fetching
modem and line state in open and when retrieving registers.

This specifically makes sure that an errno is returned to user space on
errors in TIOCMGET instead of a zero bitmask.

Also drop the unused getdevice function which also lacked appropriate
error handling.

Fixes: f7a33e608d9a ("USB: serial: add quatech2 usb to serial driver")
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/quatech2.c |   24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

--- a/drivers/usb/serial/quatech2.c
+++ b/drivers/usb/serial/quatech2.c
@@ -188,22 +188,22 @@ static inline int qt2_setdevice(struct u
 }
 
 
-static inline int qt2_getdevice(struct usb_device *dev, u8 *data)
-{
-	return usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
-			       QT_SET_GET_DEVICE, 0xc0, 0, 0,
-			       data, 3, QT2_USB_TIMEOUT);
-}
-
 static inline int qt2_getregister(struct usb_device *dev,
 				  u8 uart,
 				  u8 reg,
 				  u8 *data)
 {
-	return usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
-			       QT_SET_GET_REGISTER, 0xc0, reg,
-			       uart, data, sizeof(*data), QT2_USB_TIMEOUT);
+	int ret;
 
+	ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
+			      QT_SET_GET_REGISTER, 0xc0, reg,
+			      uart, data, sizeof(*data), QT2_USB_TIMEOUT);
+	if (ret < sizeof(*data)) {
+		if (ret >= 0)
+			ret = -EIO;
+	}
+
+	return ret;
 }
 
 static inline int qt2_setregister(struct usb_device *dev,
@@ -372,9 +372,11 @@ static int qt2_open(struct tty_struct *t
 				 0xc0, 0,
 				 device_port, data, 2, QT2_USB_TIMEOUT);
 
-	if (status < 0) {
+	if (status < 2) {
 		dev_err(&port->dev, "%s - open port failed %i\n", __func__,
 			status);
+		if (status >= 0)
+			status = -EIO;
 		kfree(data);
 		return status;
 	}


Patches currently in stable-queue which might be from johan@kernel.org are

queue-4.9/usb-serial-mct_u232-fix-modem-status-error-handling.patch
queue-4.9/usb-serial-ark3116-fix-open-error-handling.patch
queue-4.9/usb-serial-io_edgeport-fix-epic-descriptor-handling.patch
queue-4.9/usb-serial-ti_usb_3410_5052-fix-control-message-error-handling.patch
queue-4.9/usb-serial-keyspan_pda-fix-receive-sanity-checks.patch
queue-4.9/usb-serial-sierra-fix-bogus-alternate-setting-assumption.patch
queue-4.9/usb-serial-ssu100-fix-control-message-error-handling.patch
queue-4.9/usb-serial-digi_acceleport-fix-incomplete-rx-sanity-check.patch
queue-4.9/usb-serial-io_edgeport-fix-descriptor-error-handling.patch
queue-4.9/usb-serial-quatech2-fix-control-message-error-handling.patch
queue-4.9/usb-serial-ftdi_sio-fix-latency-timer-error-handling.patch

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-05-09  9:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-09  9:42 Patch "USB: serial: quatech2: fix control-message error handling" has been added to the 4.9-stable tree gregkh

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.