Skip to contentSkip to conversation

qdev: skip bus check for bus-less devices in qdev_unplug()

PATCH Applied Igor Mammedov 2 participants 2 messages May 3, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qdev: skip bus check for bus-less devices in qdev_unplug()

Since commit 2f7bd829db "qdev: Fix device_add bus assumptions" it's possible to device_add bus-less device, but if such device is unplugged it will dereference NULL parent_bus in qdev_unplug().

Fix it by taking in account that parent_bus might be NULL and skipping bus check.

---
 hw/core/qdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/core/qdev.c +1 -1
index ab1d8f5..069ac90 100644
@@ -208,7 +208,7 @@ void qdev_unplug(DeviceState *dev, Error **errp)
 {
     DeviceClass *dc = DEVICE_GET_CLASS(dev);
 
-    if (!dev->parent_bus->allow_hotplug) {
+    if (dev->parent_bus && !dev->parent_bus->allow_hotplug) {
         error_set(errp, QERR_BUS_NO_HOTPLUG, dev->parent_bus->name);
         return;
     }
Signature · 1 line
1.8.2.1