]> git.itanic.dy.fi Git - linux-stable/blobdiff - drivers/i2c/busses/i2c-mlxbf.c
i2c: mlxbf: prevent stack overflow in mlxbf_i2c_smbus_start_transaction()
[linux-stable] / drivers / i2c / busses / i2c-mlxbf.c
index 612736906440d5e8dd08176a8b02f94f3b5aaaa4..ac93c0ccf53c541811e424aa6e8ed6b0d94b9e28 100644 (file)
@@ -738,6 +738,9 @@ mlxbf_i2c_smbus_start_transaction(struct mlxbf_i2c_priv *priv,
                if (flags & MLXBF_I2C_F_WRITE) {
                        write_en = 1;
                        write_len += operation->length;
+                       if (data_idx + operation->length >
+                                       MLXBF_I2C_MASTER_DATA_DESC_SIZE)
+                               return -ENOBUFS;
                        memcpy(data_desc + data_idx,
                               operation->buffer, operation->length);
                        data_idx += operation->length;