Return when i2c transfer 0 messages

msg->flags is accessed without proper intialized msg variable.
This commit is contained in:
Howard Su 2021-02-28 16:42:27 +08:00
parent 2bf53d315d
commit 5a184c19b2
1 changed files with 2 additions and 0 deletions

View File

@ -375,6 +375,8 @@ static rt_size_t i2c_bit_xfer(struct rt_i2c_bus_device *bus,
rt_int32_t i, ret;
rt_uint16_t ignore_nack;
if (num == 0) return 0;
for (i = 0; i < num; i++)
{
msg = &msgs[i];