aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/serial/safe_serial.c43
1 files changed, 21 insertions, 22 deletions
diff --git a/drivers/usb/serial/safe_serial.c b/drivers/usb/serial/safe_serial.c
index d9af5c5ed9e8..a36e2313eed0 100644
--- a/drivers/usb/serial/safe_serial.c
+++ b/drivers/usb/serial/safe_serial.c
@@ -218,7 +218,9 @@ static void safe_process_read_urb(struct urb *urb)
218 struct usb_serial_port *port = urb->context; 218 struct usb_serial_port *port = urb->context;
219 unsigned char *data = urb->transfer_buffer; 219 unsigned char *data = urb->transfer_buffer;
220 unsigned char length = urb->actual_length; 220 unsigned char length = urb->actual_length;
221 int actual_length;
221 struct tty_struct *tty; 222 struct tty_struct *tty;
223 __u16 fcs;
222 224
223 if (!length) 225 if (!length)
224 return; 226 return;
@@ -227,30 +229,27 @@ static void safe_process_read_urb(struct urb *urb)
227 if (!tty) 229 if (!tty)
228 return; 230 return;
229 231
230 if (safe) { 232 if (!safe)
231 __u16 fcs; 233 goto out;
232 fcs = fcs_compute10(data, length, CRC10_INITFCS); 234
233 if (!fcs) { 235 fcs = fcs_compute10(data, length, CRC10_INITFCS);
234 int actual_length = data[length - 2] >> 2; 236 if (fcs) {
235 if (actual_length <= (length - 2)) { 237 dev_err(&port->dev, "%s - bad CRC %x\n", __func__, fcs);
236 dev_info(&urb->dev->dev, "%s - actual: %d\n", 238 goto err;
237 __func__, actual_length);
238 tty_insert_flip_string(tty,
239 data, actual_length);
240 tty_flip_buffer_push(tty);
241 } else {
242 dev_err(&port->dev,
243 "%s - inconsistent lengths %d:%d\n",
244 __func__, actual_length, length);
245 }
246 } else {
247 dev_err(&port->dev, "%s - bad CRC %x\n", __func__, fcs);
248 }
249 } else {
250 tty_insert_flip_string(tty, data, length);
251 tty_flip_buffer_push(tty);
252 } 239 }
253 240
241 actual_length = data[length - 2] >> 2;
242 if (actual_length > (length - 2)) {
243 dev_err(&port->dev, "%s - inconsistent lengths %d:%d\n",
244 __func__, actual_length, length);
245 goto err;
246 }
247 dev_info(&urb->dev->dev, "%s - actual: %d\n", __func__, actual_length);
248 length = actual_length;
249out:
250 tty_insert_flip_string(tty, data, length);
251 tty_flip_buffer_push(tty);
252err:
254 tty_kref_put(tty); 253 tty_kref_put(tty);
255} 254}
256 255