cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-qdev-monitor-Fix-crash-when-device_add-is-called.2.patch.patch

0a122b
From 26c346739c8772521b68e4763321d7bdfc49efd4 Mon Sep 17 00:00:00 2001
0a122b
From: Markus Armbruster <armbru@redhat.com>
0a122b
Date: Fri, 17 Jan 2014 17:07:54 +0100
0a122b
Subject: [PATCH 04/11] qdev-monitor: Fix crash when device_add is called with abstract driver
0a122b
MIME-Version: 1.0
0a122b
Content-Type: text/plain; charset=UTF-8
0a122b
Content-Transfer-Encoding: 8bit
0a122b
0a122b
RH-Author: Markus Armbruster <armbru@redhat.com>
0a122b
Message-id: <1389978479-30595-5-git-send-email-armbru@redhat.com>
0a122b
Patchwork-id: 56787
0a122b
O-Subject: [PATCH 7.0 qemu-kvm 4/9] qdev-monitor: Fix crash when device_add is called with abstract driver
0a122b
Bugzilla: 669524
0a122b
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
0a122b
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
0a122b
RH-Acked-by: Marcel Apfelbaum <marcel.a@redhat.com>
0a122b
0a122b
From: Igor Mammedov <imammedo@redhat.com>
0a122b
0a122b
User is able to crash running QEMU when following monitor
0a122b
command is called:
0a122b
0a122b
 device_add intel-hda-generic
0a122b
0a122b
Crash is caused by assertion in object_initialize_with_type()
0a122b
when type is abstract.
0a122b
0a122b
Checking if type is abstract before instance is created in
0a122b
qdev_device_add() allows to prevent crash on incorrect user input.
0a122b
0a122b
Cc: qemu-stable@nongnu.org
0a122b
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
0a122b
Signed-off-by: Andreas Färber <afaerber@suse.de>
0a122b
(cherry picked from commit 2fa4e56d88aa0039062bbc7f9a88e9f90c77ed94)
0a122b
Signed-off-by: Markus Armbruster <armbru@redhat.com>
0a122b
---
0a122b
 qdev-monitor.c | 6 ++++++
0a122b
 1 file changed, 6 insertions(+)
0a122b
0a122b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
0a122b
---
0a122b
 qdev-monitor.c |    6 ++++++
0a122b
 1 files changed, 6 insertions(+), 0 deletions(-)
0a122b
0a122b
diff --git a/qdev-monitor.c b/qdev-monitor.c
0a122b
index 5b45d02..f313a94 100644
0a122b
--- a/qdev-monitor.c
0a122b
+++ b/qdev-monitor.c
0a122b
@@ -482,6 +482,12 @@ DeviceState *qdev_device_add(QemuOpts *opts)
0a122b
         return NULL;
0a122b
     }
0a122b
 
0a122b
+    if (object_class_is_abstract(oc)) {
0a122b
+        qerror_report(QERR_INVALID_PARAMETER_VALUE, "driver",
0a122b
+                      "non-abstract device type");
0a122b
+        return NULL;
0a122b
+    }
0a122b
+
0a122b
     dc = DEVICE_CLASS(oc);
0a122b
 
0a122b
     /* find bus */
0a122b
-- 
0a122b
1.7.1
0a122b