Skip to content

Commit

Permalink
i2c: mlxcpld: check correct size of maximum RECV_LEN packet
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Wolfram Sang authored and wsakernel committed Jul 4, 2020
1 parent 58e64b0 commit 5979112
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/i2c/busses/i2c-mlxcpld.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,9 @@ static int mlxcpld_i2c_wait_for_tc(struct mlxcpld_i2c_priv *priv)
if (priv->smbus_block && (val & MLXCPLD_I2C_SMBUS_BLK_BIT)) {
mlxcpld_i2c_read_comm(priv, MLXCPLD_LPCI2C_NUM_DAT_REG,
&datalen, 1);
if (unlikely(datalen > (I2C_SMBUS_BLOCK_MAX + 1))) {
if (unlikely(datalen > I2C_SMBUS_BLOCK_MAX)) {
dev_err(priv->dev, "Incorrect smbus block read message len\n");
return -E2BIG;
return -EPROTO;
}
} else {
datalen = priv->xfer.data_len;
Expand Down

0 comments on commit 5979112

Please sign in to comment.