Skip to content

Commit 2856a62

Browse files
jk-ozlabsdavem330
authored andcommitted
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: a0c2ccd ("mctp: Add MCTP-over-serial transport binding") Reported-by: Harsh Tyagi <[email protected]> Tested-by: Harsh Tyagi <[email protected]> Signed-off-by: Jeremy Kerr <[email protected]> Reviewed-by: Alexander Duyck <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 1b0c84a commit 2856a62

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/net/mctp/mctp-serial.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
#define BYTE_FRAME 0x7e
3636
#define BYTE_ESC 0x7d
3737

38+
#define FCS_INIT 0xffff
39+
3840
static DEFINE_IDA(mctp_serial_ida);
3941

4042
enum mctp_serial_state {
@@ -123,7 +125,7 @@ static void mctp_serial_tx_work(struct work_struct *work)
123125
buf[2] = dev->txlen;
124126

125127
if (!dev->txpos)
126-
dev->txfcs = crc_ccitt(0, buf + 1, 2);
128+
dev->txfcs = crc_ccitt(FCS_INIT, buf + 1, 2);
127129

128130
txlen = write_chunk(dev, buf + dev->txpos, 3 - dev->txpos);
129131
if (txlen <= 0) {
@@ -303,7 +305,7 @@ static void mctp_serial_push_header(struct mctp_serial *dev, unsigned char c)
303305
case 1:
304306
if (c == MCTP_SERIAL_VERSION) {
305307
dev->rxpos++;
306-
dev->rxfcs = crc_ccitt_byte(0, c);
308+
dev->rxfcs = crc_ccitt_byte(FCS_INIT, c);
307309
} else {
308310
dev->rxstate = STATE_ERR;
309311
}

0 commit comments

Comments
 (0)