From 5a184c19b21bcc946697b8c83f6a43b6200aa02f Mon Sep 17 00:00:00 2001 From: Howard Su Date: Sun, 28 Feb 2021 16:42:27 +0800 Subject: [PATCH] Return when i2c transfer 0 messages msg->flags is accessed without proper intialized msg variable. --- components/drivers/i2c/i2c-bit-ops.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/drivers/i2c/i2c-bit-ops.c b/components/drivers/i2c/i2c-bit-ops.c index 96af567a1e..3a9b4efeb3 100644 --- a/components/drivers/i2c/i2c-bit-ops.c +++ b/components/drivers/i2c/i2c-bit-ops.c @@ -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];