ensure SMBusDeviceClass::init is set before calling it Signed-off-by: Philippe Mathieu-Daudé <f4...@amsat.org> --- hw/i2c/smbus.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/hw/i2c/smbus.c b/hw/i2c/smbus.c index 2d1b79a689..a90d65ef37 100644 --- a/hw/i2c/smbus.c +++ b/hw/i2c/smbus.c @@ -207,7 +207,11 @@ static int smbus_device_init(I2CSlave *i2c) SMBusDevice *dev = SMBUS_DEVICE(i2c); SMBusDeviceClass *sc = SMBUS_DEVICE_GET_CLASS(dev); - return sc->init(dev); + if (sc->init) { + return sc->init(dev); + } + + return 0; } /* Master device commands. */ -- 2.15.1