diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c index 57a45ce8..b8f226a0 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c @@ -270,9 +270,10 @@ static noinline int i2cdev_ioctl_rdrw(struct i2c_client *client, res = 0; for (i = 0; i < rdwr_arg.nmsgs; i++) { /* Limit the size of the message to a sane amount; - * and don't let length change either. */ + * with I2C_M_RECV_LEN require worst case len. */ if ((rdwr_pa[i].len > 8192) || - (rdwr_pa[i].flags & I2C_M_RECV_LEN)) { + ((rdwr_pa[i].flags & I2C_M_RECV_LEN) && + (rdwr_pa[i].len < 256))) { res = -EINVAL; break; }