From 2f46d99451b1e6e5102dae959f16e48175c4bb88 Mon Sep 17 00:00:00 2001 From: Nabih Estefan Date: Tue, 20 Jan 2026 21:11:16 +0000 Subject: [PATCH] hw/i2c/aspeed_i2c.c: Add a check for dma_read MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If aspeed_i2c_dma_read fails in aspeed_i2c_bus_send currently, we get stuck in an infinite retry loop. Add a check for the return value of aspeed_i2c_dma_read that will break us out of said loop. Signed-off-by: Nabih Estefan Reviewed-by: Cédric Le Goater Fixes: 545d6bef7097 ("aspeed/i2c: Add support for DMA transfers") Link: https://lore.kernel.org/qemu-devel/20260120211116.1367476-1-nabihestefan@google.com Signed-off-by: Cédric Le Goater (cherry picked from commit 0a1d4770670297a1da52118f84812e4a5ffc7722) Signed-off-by: Michael Tokarev --- hw/i2c/aspeed_i2c.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/i2c/aspeed_i2c.c b/hw/i2c/aspeed_i2c.c index 83fb906bdc..765a98b698 100644 --- a/hw/i2c/aspeed_i2c.c +++ b/hw/i2c/aspeed_i2c.c @@ -272,7 +272,11 @@ static int aspeed_i2c_bus_send(AspeedI2CBus *bus) } while (bus->regs[reg_dma_len]) { uint8_t data; - aspeed_i2c_dma_read(bus, &data); + ret = aspeed_i2c_dma_read(bus, &data); + /* Check that we were able to read the DMA */ + if (ret) { + break; + } trace_aspeed_i2c_bus_send("DMA", bus->regs[reg_dma_len], bus->regs[reg_dma_len], data); ret = i2c_send(bus->bus, data);