1
0
Fork 0

MLK-17108-4 staging: typec: tcpci: correct read data msg length

Per tcpci spec, the TCPC_RX_BYTE_CNT is the number of bytes in the
RX_BUFFER_DATA_OBJECTS plus three (for the RX_BUF_FRAME_TYPE and
RX_BUF_HEADER), so after read out the header, we should only read
TCPC_RX_BYTE_CNT-3 bytes for data if this is a data message.

Acked-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
pull/10/head
Li Jun 2018-01-25 20:01:46 +08:00 committed by Jason Liu
parent 4adece561e
commit a7246ec48c
1 changed files with 6 additions and 0 deletions

View File

@ -581,6 +581,12 @@ static irqreturn_t tcpci_irq(int irq, void *dev_id)
tcpci_read16(tcpci, TCPC_RX_HDR, &reg);
msg.header = reg;
/*
* TCPC_RX_BYTE_CNT is the number of bytes in the
* RX_BUFFER_DATA_OBJECTS plus three (for the RX_BUF_FRAME_TYPE
* and RX_BUF_HEADER).
*/
cnt -= 3;
if (WARN_ON(cnt > sizeof(msg.payload)))
cnt = sizeof(msg.payload);