Re: [PATCH v6 02/10] i2c: cgbc: Propagate hardware errors when polling read status
From: Andi Shyti
Date: Thu Nov 26 2026 - 08:34:19 EST
Hi,
On Tue, Nov 17, 2026 at 10:47:42AM +0100, Thomas Richard (congatec GmbH) wrote:
> From: Lee Jones <lee@xxxxxxxxxx>
>
> In cgbc_i2c_xfer_msg(), read_poll_timeout() uses the same ret variable
> to store the polled return value of cgbc_i2c_get_status() and the
> timeout result of the macro itself. When cgbc_i2c_get_status() returns
> a negative error code (such as -EIO on an I2C NACK), the loop condition
> ret != CGBC_I2C_STAT_BUSY evaluates to true and read_poll_timeout()
> overwrites ret with 0. The driver then issues CGBC_I2C_CMD_DATA, which
> completes with CGBC_STATUS_CMD_READY without populating msg->buf,
> leaving uninitialised heap memory in the caller's read buffer.
>
> Store the polled status in a separate variable, verify that it equals
> CGBC_I2C_STAT_DAT, and check that CGBC_I2C_CMD_DATA returns the expected
> number of bytes.
>
> Fixes: 6894f640b8f3 ("i2c: Congatec Board Controller i2c bus driver")
> Closes: https://sashiko.dev/#/bug/linux-66cbf4b1-a219-4012-969d-236417bf419a
> Cc: stable@xxxxxxxxxxxxxxx
> Reviewed-by: Thomas Richard (congatec GmbH) <thomas.richard@xxxxxxxxxxx>
> Tested-by: Thomas Richard (congatec GmbH) <thomas.richard@xxxxxxxxxxx>
> Signed-off-by: Lee Jones <lee@xxxxxxxxxx>
> Signed-off-by: Thomas Richard (congatec GmbH) <thomas.richard@xxxxxxxxxxx>
Reviewed-by: Andi Shyti <andi.shyti@xxxxxxxxxx>
Thanks,
Andi