From 2fa4e56d88aa0039062bbc7f9a88e9f90c77ed94 Mon Sep 17 00:00:00 2001 From: Igor Mammedov Date: Tue, 17 Sep 2013 15:32:32 +0200 Subject: qdev-monitor: Fix crash when device_add is called with abstract driver MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit User is able to crash running QEMU when following monitor command is called: device_add intel-hda-generic Crash is caused by assertion in object_initialize_with_type() when type is abstract. Checking if type is abstract before instance is created in qdev_device_add() allows to prevent crash on incorrect user input. Cc: qemu-stable@nongnu.org Signed-off-by: Igor Mammedov Signed-off-by: Andreas Färber --- qdev-monitor.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'qdev-monitor.c') diff --git a/qdev-monitor.c b/qdev-monitor.c index 8f9f6cb45f..753bab7545 100644 --- a/qdev-monitor.c +++ b/qdev-monitor.c @@ -481,6 +481,12 @@ DeviceState *qdev_device_add(QemuOpts *opts) return NULL; } + if (object_class_is_abstract(oc)) { + qerror_report(QERR_INVALID_PARAMETER_VALUE, "driver", + "non-abstract device type"); + return NULL; + } + dc = DEVICE_CLASS(oc); /* find bus */ -- cgit v1.2.1