Skip to content

Commit 9f0ca75

Browse files
TonyHan11danieldegrasse
authored andcommitted
drivers: i2c: sam: fix the exception when transferring without data
The issue is found when doing shell command "i2c scan" on sama7g54-ek. In this case no data will be transferred besides START and STOP. Data abort would occur on accessing "msg->buf[msg->idx++]" when MMU is enabled and "msg->idx" is very large. Signed-off-by: Tony Han <tony.han@microchip.com>
1 parent 0427756 commit 9f0ca75

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/i2c/i2c_sam_twi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ static void i2c_sam_twi_isr(const struct device *dev)
293293

294294
/* Byte sent */
295295
if (isr_status & TWI_SR_TXRDY) {
296-
if (msg->idx == msg->len) {
296+
if (msg->idx == msg->len || msg->len == 0) {
297297
if (msg->flags & I2C_MSG_STOP) {
298298
/* Send a STOP condition on the TWI */
299299
twi->TWI_CR = TWI_CR_STOP;

0 commit comments

Comments
 (0)