From: Amit Shah Date: Mon, 2 Nov 2009 09:26:41 +0000 (+0530) Subject: qdev: Check if unplug handler exists before calling it X-Git-Tag: v0.12.0-rc0~335 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=593831de5dce5f5b9ce1226e0d8353eecb1176e4;p=thirdparty%2Fqemu.git qdev: Check if unplug handler exists before calling it A bus may have hotplugging enabled but not have the 'unplug' callback defined, which would lead to a crash on trying to unplug a device on the bus. Fix by introducing an assert to check if the callback is valid. Signed-off-by: Amit Shah Signed-off-by: Anthony Liguori --- diff --git a/hw/qdev.c b/hw/qdev.c index c7884d0e824..d19d531402a 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -258,6 +258,8 @@ int qdev_unplug(DeviceState *dev) dev->parent_bus->name); return -1; } + assert(dev->info->unplug != NULL); + return dev->info->unplug(dev); }