diff --git a/drivers/i2c/i2c-core-smbus.c b/drivers/i2c/i2c-core-smbus.c index e73afbefe222..404f5c71408c 100644 --- a/drivers/i2c/i2c-core-smbus.c +++ b/drivers/i2c/i2c-core-smbus.c @@ -81,6 +81,8 @@ static inline void i2c_smbus_add_pec(struct i2c_msg *msg) message length to hide the CRC byte from the caller). */ static int i2c_smbus_check_pec(u8 cpec, struct i2c_msg *msg) { + if (!msg || msg->len == 0 || !msg->buf)// -fix /////////////////////////////////// + return -EINVAL; u8 rpec = msg->buf[--msg->len]; cpec = i2c_smbus_msg_pec(cpec, msg); @@ -478,6 +480,7 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter *adapter, u16 addr, /* Check PEC if last message is a read */ if (wants_pec && (msg[nmsgs - 1].flags & I2C_M_RD)) { status = i2c_smbus_check_pec(partial_pec, &msg[nmsgs - 1]); + memset(msg[nmsgs -1].buf, 0,msg[nmsgs-1].len); //- fix //////////////////////// if (status < 0) goto cleanup; }