Re: [PATCH v2] i2c: designware: Only check the first byte for SMBus block read length

From: Jarkko Nikula
Date: Wed Jun 17 2020 - 07:17:18 EST


On 6/16/20 6:43 PM, Sultan Alsawaf wrote:
From: Sultan Alsawaf <sultan@xxxxxxxxxxxxxxx>

SMBus block reads can be broken because the read function will just skip
over bytes it doesn't like until reaching a byte that conforms to the
length restrictions for block reads. This is problematic when it isn't
known if the incoming payload is indeed a conforming block read.

According to the SMBus specification, block reads will only send the
payload length in the first byte, so we can fix this by only considering
the first byte in a sequence for block read length purposes.

Fixes: c3ae106050b9 ("i2c: designware: Implement support for SMBus block read and write")
Signed-off-by: Sultan Alsawaf <sultan@xxxxxxxxxxxxxxx>
---
drivers/i2c/busses/i2c-designware-master.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)

Acked-by: Jarkko Nikula <jarkko.nikula@xxxxxxxxxxxxxxx>