aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/keyspan.c
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2013-04-05 01:43:20 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-04-05 17:11:25 -0400
commit01a60e76b6392547ad3dca3ac05b9c886fa5da45 (patch)
tree5fe22932e6ad9f325e43a374d3cd5376117fd047 /drivers/usb/serial/keyspan.c
parent6a3ae8412f9e9cee0e8647954f4f7f2c50664ca2 (diff)
USB: keyspan: add a sanity test on "len"
"len" comes from the USB transfer and it's probably correct. The thing is that we already have similar checks like: if (data[i] >= serial->num_ports) { So adding a sanity test here matches the rest of the code and is a good idea. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/serial/keyspan.c')
-rw-r--r--drivers/usb/serial/keyspan.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
index 3d92394aba3a..025310bc358a 100644
--- a/drivers/usb/serial/keyspan.c
+++ b/drivers/usb/serial/keyspan.c
@@ -741,14 +741,15 @@ static void usa49wg_indat_callback(struct urb *urb)
741 if ((data[i] & 0x80) == 0) { 741 if ((data[i] & 0x80) == 0) {
742 /* no error on any byte */ 742 /* no error on any byte */
743 i++; 743 i++;
744 for (x = 1; x < len ; ++x) 744 for (x = 1; x < len && i < urb->actual_length; ++x)
745 tty_insert_flip_char(&port->port, 745 tty_insert_flip_char(&port->port,
746 data[i++], 0); 746 data[i++], 0);
747 } else { 747 } else {
748 /* 748 /*
749 * some bytes had errors, every byte has status 749 * some bytes had errors, every byte has status
750 */ 750 */
751 for (x = 0; x + 1 < len; x += 2) { 751 for (x = 0; x + 1 < len &&
752 i + 1 < urb->actual_length; x += 2) {
752 int stat = data[i], flag = 0; 753 int stat = data[i], flag = 0;
753 754
754 if (stat & RXERROR_OVERRUN) 755 if (stat & RXERROR_OVERRUN)