]> xenbits.xensource.com Git - qemu-upstream-4.4-testing.git/commitdiff
qdev-monitor: Fix crash when device_add is called with abstract driver
authorIgor Mammedov <imammedo@redhat.com>
Tue, 17 Sep 2013 13:32:32 +0000 (15:32 +0200)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Mon, 9 Dec 2013 17:40:30 +0000 (11:40 -0600)
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 <imammedo@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
(cherry picked from commit 2fa4e56d88aa0039062bbc7f9a88e9f90c77ed94)

Conflicts:

qdev-monitor.c

*updated to reflect different 1.6 variable names

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
qdev-monitor.c

index 410cdcbe97bc7510a6a4fe75e63f95a89c1100cf..bb2e1b6ab9ae79649ecb990af9c25295f6028ef4 100644 (file)
@@ -472,6 +472,12 @@ DeviceState *qdev_device_add(QemuOpts *opts)
         return NULL;
     }
 
+    if (object_class_is_abstract(obj)) {
+        qerror_report(QERR_INVALID_PARAMETER_VALUE, "driver",
+                      "non-abstract device type");
+        return NULL;
+    }
+
     k = DEVICE_CLASS(obj);
 
     /* find bus */