Skip to content

Commit 5979112

Browse files
Wolfram Sangwsakernel
authored andcommitted
i2c: mlxcpld: check correct size of maximum RECV_LEN packet
I2C_SMBUS_BLOCK_MAX defines already the maximum number as defined in the SMBus 2.0 specs. I don't see a reason to add 1 here. Also, fix the errno to what is suggested for this error. Fixes: c9bfdc7 ("i2c: mlxcpld: Add support for smbus block read transaction") Signed-off-by: Wolfram Sang <[email protected]> Reviewed-by: Michael Shych <[email protected]> Tested-by: Michael Shych <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
1 parent 58e64b0 commit 5979112

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/i2c/busses/i2c-mlxcpld.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,9 @@ static int mlxcpld_i2c_wait_for_tc(struct mlxcpld_i2c_priv *priv)
337337
if (priv->smbus_block && (val & MLXCPLD_I2C_SMBUS_BLK_BIT)) {
338338
mlxcpld_i2c_read_comm(priv, MLXCPLD_LPCI2C_NUM_DAT_REG,
339339
&datalen, 1);
340-
if (unlikely(datalen > (I2C_SMBUS_BLOCK_MAX + 1))) {
340+
if (unlikely(datalen > I2C_SMBUS_BLOCK_MAX)) {
341341
dev_err(priv->dev, "Incorrect smbus block read message len\n");
342-
return -E2BIG;
342+
return -EPROTO;
343343
}
344344
} else {
345345
datalen = priv->xfer.data_len;

0 commit comments

Comments
 (0)