]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
i2c: designware: Handle invalid SMBus block data response length value
authorTam Nguyen <tamnguyenchi@os.amperecomputing.com>
Wed, 26 Jul 2023 08:00:01 +0000 (15:00 +0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 26 Aug 2023 12:23:32 +0000 (14:23 +0200)
commit080dedb1cad81c5f3d9a0aa1451622c60616f95a
tree83076bb37635c6b69332f8fff49d222a4c17df8f
parent416c538684bd62f6f08291f25294470356c87da0
i2c: designware: Handle invalid SMBus block data response length value

commit 69f035c480d76f12bf061148ccfd578e1099e5fc upstream.

In the I2C_FUNC_SMBUS_BLOCK_DATA case, the invalid length byte value
(outside of 1-32) of the SMBus block data response from the Slave device
is not correctly handled by the I2C Designware driver.

In case IC_EMPTYFIFO_HOLD_MASTER_EN==1, which cannot be detected
from the registers, the Master can be disabled only if the STOP bit
is set. Without STOP bit set, the Master remains active, holding the bus
until receiving a block data response length. This hangs the bus and
is unrecoverable.

Avoid this by issuing another dump read to reach the stop condition when
an invalid length byte is received.

Cc: stable@vger.kernel.org
Signed-off-by: Tam Nguyen <tamnguyenchi@os.amperecomputing.com>
Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Link: https://lore.kernel.org/r/20230726080001.337353-3-tamnguyenchi@os.amperecomputing.com
Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/i2c/busses/i2c-designware-master.c