summaryrefslogtreecommitdiff
path: root/components/drivers/i2c
diff options
context:
space:
mode:
authorHoward Su <[email protected]>2021-02-28 16:42:27 +0800
committerHoward Su <[email protected]>2021-02-28 16:42:27 +0800
commit5a184c19b21bcc946697b8c83f6a43b6200aa02f (patch)
tree6c5edd16b032834e25ed9f515d392acb1e2e6613 /components/drivers/i2c
parent2bf53d315d62bd199c01fd2d6a7f05d1a6712153 (diff)
Return when i2c transfer 0 messages
msg->flags is accessed without proper intialized msg variable.
Diffstat (limited to 'components/drivers/i2c')
-rw-r--r--components/drivers/i2c/i2c-bit-ops.c2
1 files changed, 2 insertions, 0 deletions
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];