i2c: imx: preserve error state in block data length handler

When a block read returns an invalid length, zero or >I2C_SMBUS_BLOCK_MAX,
the length handler sets the state to IMX_I2C_STATE_FAILED. However,
i2c_imx_master_isr() unconditionally overwrites this with
IMX_I2C_STATE_READ_CONTINUE, causing an endless read loop that overruns
buffers and crashes the system.

Guard the state transition to preserve error states set by the length
handler.

Fixes: 5f5c2d4579ca ("i2c: imx: prevent rescheduling in non dma mode")
Signed-off-by: LI Qingwu <Qing-wu.Li@leica-geosystems.com.cn>
Cc: <stable@vger.kernel.org> # v6.13+
Reviewed-by: Stefan Eichenberger <eichest@gmail.com>
Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
Link: https://lore.kernel.org/r/20260116111906.3413346-2-Qing-wu.Li@leica-geosystems.com.cn
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

authored by LI Qingwu and committed by Wolfram Sang b126097b 18f7fcd5

+2 -1
+2 -1
drivers/i2c/busses/i2c-imx.c
··· 1103 1103 1104 1104 case IMX_I2C_STATE_READ_BLOCK_DATA_LEN: 1105 1105 i2c_imx_isr_read_block_data_len(i2c_imx); 1106 - i2c_imx->state = IMX_I2C_STATE_READ_CONTINUE; 1106 + if (i2c_imx->state == IMX_I2C_STATE_READ_BLOCK_DATA_LEN) 1107 + i2c_imx->state = IMX_I2C_STATE_READ_CONTINUE; 1107 1108 break; 1108 1109 1109 1110 case IMX_I2C_STATE_WRITE: