Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mctp: serial: Fix starting value for frame check sequence

RFC1662 defines the start state for the crc16 FCS to be 0xffff, but
we're currently starting at zero.

This change uses the correct start state. We're only early in the
adoption for the serial binding, so there aren't yet any other users to
interface to.

Fixes: a0c2ccd9b5ad ("mctp: Add MCTP-over-serial transport binding")
Reported-by: Harsh Tyagi <harshtya@google.com>
Tested-by: Harsh Tyagi <harshtya@google.com>
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Reviewed-by: Alexander Duyck <alexanderduyck@fb.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Jeremy Kerr and committed by
David S. Miller
2856a627 1b0c84a3

+4 -2
+4 -2
drivers/net/mctp/mctp-serial.c
··· 35 35 #define BYTE_FRAME 0x7e 36 36 #define BYTE_ESC 0x7d 37 37 38 + #define FCS_INIT 0xffff 39 + 38 40 static DEFINE_IDA(mctp_serial_ida); 39 41 40 42 enum mctp_serial_state { ··· 125 123 buf[2] = dev->txlen; 126 124 127 125 if (!dev->txpos) 128 - dev->txfcs = crc_ccitt(0, buf + 1, 2); 126 + dev->txfcs = crc_ccitt(FCS_INIT, buf + 1, 2); 129 127 130 128 txlen = write_chunk(dev, buf + dev->txpos, 3 - dev->txpos); 131 129 if (txlen <= 0) { ··· 305 303 case 1: 306 304 if (c == MCTP_SERIAL_VERSION) { 307 305 dev->rxpos++; 308 - dev->rxfcs = crc_ccitt_byte(0, c); 306 + dev->rxfcs = crc_ccitt_byte(FCS_INIT, c); 309 307 } else { 310 308 dev->rxstate = STATE_ERR; 311 309 }