diff --git a/hw/i2c.c b/hw/i2c.c index 5c291ce0a9..bee8e88c6b 100644 --- a/hw/i2c.c +++ b/hw/i2c.c @@ -85,9 +85,11 @@ int i2c_start_transfer(i2c_bus *bus, uint8_t address, int recv) i2c_slave *slave = NULL; QLIST_FOREACH(qdev, &bus->qbus.children, sibling) { - slave = I2C_SLAVE_FROM_QDEV(qdev); - if (slave->address == address) + i2c_slave *candidate = I2C_SLAVE_FROM_QDEV(qdev); + if (candidate->address == address) { + slave = candidate; break; + } } if (!slave)