Skip to content

Commit 5a184c1

Browse files
committed
Return when i2c transfer 0 messages
msg->flags is accessed without proper intialized msg variable.
1 parent 2bf53d3 commit 5a184c1

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

components/drivers/i2c/i2c-bit-ops.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,8 @@ static rt_size_t i2c_bit_xfer(struct rt_i2c_bus_device *bus,
375375
rt_int32_t i, ret;
376376
rt_uint16_t ignore_nack;
377377

378+
if (num == 0) return 0;
379+
378380
for (i = 0; i < num; i++)
379381
{
380382
msg = &msgs[i];

0 commit comments

Comments
 (0)