aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/can/mcp251x.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/can/mcp251x.c')
-rw-r--r--drivers/net/can/mcp251x.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/drivers/net/can/mcp251x.c b/drivers/net/can/mcp251x.c
index 78b1b69b2921..9c5a1537939c 100644
--- a/drivers/net/can/mcp251x.c
+++ b/drivers/net/can/mcp251x.c
@@ -403,9 +403,8 @@ static void mcp251x_hw_rx_frame(struct spi_device *spi, u8 *buf,
403 403
404 for (i = 1; i < RXBDAT_OFF; i++) 404 for (i = 1; i < RXBDAT_OFF; i++)
405 buf[i] = mcp251x_read_reg(spi, RXBCTRL(buf_idx) + i); 405 buf[i] = mcp251x_read_reg(spi, RXBCTRL(buf_idx) + i);
406 len = buf[RXBDLC_OFF] & RXBDLC_LEN_MASK; 406
407 if (len > 8) 407 len = get_can_dlc(buf[RXBDLC_OFF] & RXBDLC_LEN_MASK);
408 len = 8;
409 for (; i < (RXBDAT_OFF + len); i++) 408 for (; i < (RXBDAT_OFF + len); i++)
410 buf[i] = mcp251x_read_reg(spi, RXBCTRL(buf_idx) + i); 409 buf[i] = mcp251x_read_reg(spi, RXBCTRL(buf_idx) + i);
411 } else { 410 } else {
@@ -455,13 +454,7 @@ static void mcp251x_hw_rx(struct spi_device *spi, int buf_idx)
455 (buf[RXBSIDL_OFF] >> RXBSIDL_SHIFT); 454 (buf[RXBSIDL_OFF] >> RXBSIDL_SHIFT);
456 } 455 }
457 /* Data length */ 456 /* Data length */
458 frame->can_dlc = buf[RXBDLC_OFF] & RXBDLC_LEN_MASK; 457 frame->can_dlc = get_can_dlc(buf[RXBDLC_OFF] & RXBDLC_LEN_MASK);
459 if (frame->can_dlc > 8) {
460 dev_warn(&spi->dev, "invalid frame recevied\n");
461 priv->net->stats.rx_errors++;
462 dev_kfree_skb(skb);
463 return;
464 }
465 memcpy(frame->data, buf + RXBDAT_OFF, frame->can_dlc); 458 memcpy(frame->data, buf + RXBDAT_OFF, frame->can_dlc);
466 459
467 priv->net->stats.rx_packets++; 460 priv->net->stats.rx_packets++;