summaryrefslogtreecommitdiffstats
path: root/drivers/i2c/i2c-stub.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/i2c/i2c-stub.c')
-rw-r--r--drivers/i2c/i2c-stub.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/i2c/i2c-stub.c b/drivers/i2c/i2c-stub.c
index e815c6067ff3..d241aa295d96 100644
--- a/drivers/i2c/i2c-stub.c
+++ b/drivers/i2c/i2c-stub.c
@@ -226,6 +226,8 @@ static s32 stub_xfer(struct i2c_adapter *adap, u16 addr, unsigned short flags,
* We ignore banks here, because banked chips don't use I2C
* block transfers
*/
+ if (data->block[0] > 256 - command) /* Avoid overrun */
+ data->block[0] = 256 - command;
len = data->block[0];
if (read_write == I2C_SMBUS_WRITE) {
for (i = 0; i < len; i++) {