From 5bd4decad1de4a159f09714ae4eb8f653e706df0 Mon Sep 17 00:00:00 2001 From: Omar Chebib Date: Fri, 11 Mar 2022 11:25:39 +0800 Subject: [PATCH] I2C: Read transactions, without a STOP, won't panic anymore * Closes https://github.com/espressif/esp-idf/issues/8548 --- components/driver/i2c.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/driver/i2c.c b/components/driver/i2c.c index bcd25abd9b..620b87eacd 100644 --- a/components/driver/i2c.c +++ b/components/driver/i2c.c @@ -1310,7 +1310,9 @@ static void IRAM_ATTR i2c_master_cmd_begin_static(i2c_port_t i2c_num) p_i2c->cmd_idx = 0; } else { p_i2c->cmd_link.head = p_i2c->cmd_link.head->next; - p_i2c->cmd_link.head->cmd.bytes_used = 0; + if (p_i2c->cmd_link.head != NULL) { + p_i2c->cmd_link.head->cmd.bytes_used = 0; + } } } else if ((p_i2c->status == I2C_STATUS_ACK_ERROR) || (p_i2c->status == I2C_STATUS_TIMEOUT)) {