qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 01/11] smbus: add a NULL check for SMBusDeviceClass:


From: Philippe Mathieu-Daudé
Subject: [Qemu-devel] [PATCH 01/11] smbus: add a NULL check for SMBusDeviceClass::init callbacks
Date: Tue, 16 Jan 2018 10:15:45 -0300

ensure SMBusDeviceClass::init is set before calling it

Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
---
 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]