Skip to content

Commit f962e83

Browse files
mkjdavem330
authored andcommitted
net: mctp-serial: Fix missing escapes on transmit
0x7d and 0x7e bytes are meant to be escaped in the data portion of frames, but this didn't occur since next_chunk_len() had an off-by-one error. That also resulted in the final byte of a payload being written as a separate tty write op. The chunk prior to an escaped byte would be one byte short, and the next call would never test the txpos+1 case, which is where the escaped byte was located. That meant it never hit the escaping case in mctp_serial_tx_work(). Example Input: 01 00 08 c8 7e 80 02 Previous incorrect chunks from next_chunk_len(): 01 00 08 c8 7e 80 02 With this fix: 01 00 08 c8 7e 80 02 Cc: [email protected] Fixes: a0c2ccd ("mctp: Add MCTP-over-serial transport binding") Signed-off-by: Matt Johnston <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4fa9c51 commit f962e83

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/net/mctp/mctp-serial.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ static int next_chunk_len(struct mctp_serial *dev)
9191
* will be those non-escaped bytes, and does not include the escaped
9292
* byte.
9393
*/
94-
for (i = 1; i + dev->txpos + 1 < dev->txlen; i++) {
95-
if (needs_escape(dev->txbuf[dev->txpos + i + 1]))
94+
for (i = 1; i + dev->txpos < dev->txlen; i++) {
95+
if (needs_escape(dev->txbuf[dev->txpos + i]))
9696
break;
9797
}
9898

0 commit comments

Comments
 (0)