qdev: Check if unplug handler exists before calling it
PATCH 1/1 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 <[email protected]>
--- hw/qdev.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
hw/qdev.c +2 -0
@@ -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); }
Signature · 1 line
1.6.2.5
Quoted 7 lines · Amit Shah
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<[email protected]>
Acked-by Gerd Hoffmann <[email protected]>
cheers,
Gerd