Received: from eggs.gnu.org ([2001:4830:134:3::10]:38516) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XF83S-0000cd-L3 for qemu-devel@nongnu.org; Wed, 06 Aug 2014 16:43:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XF836-0005P4-Ac for qemu-devel@nongnu.org; Wed, 06 Aug 2014 16:43:26 -0400 Received: from e39.co.us.ibm.com ([32.97.110.160]:41671) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XF836-0005Oh-2s for qemu-devel@nongnu.org; Wed, 06 Aug 2014 16:43:04 -0400 Received: from /spool/local by e39.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 6 Aug 2014 14:43:03 -0600 From: Michael Roth Date: Wed, 6 Aug 2014 15:38:44 -0500 Message-Id: <1407357598-21541-35-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1407357598-21541-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1407357598-21541-1-git-send-email-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PATCH 034/108] qdev: Fix crash by validating the object type List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org From: Amos Kong QEMU crashed when I try to list device parameters and the driver name is actually an available bus name. # qemu -device virtio-pci-bus,? # qemu -device virtio-bus,? # qemu -device virtio-serial-bus,? qdev-monitor.c:212:qdev_device_help: Object 0x7fd932f50620 is not an instance of type device Aborted (core dumped) We can also reproduce this bug by adding device from monitor, so it's worth to fix the crash. (qemu) device_add virtio-serial-bus qdev-monitor.c:491:qdev_device_add: Object 0x7f5e89530920 is not an instance of type device Aborted (core dumped) Cc: qemu-stable@nongnu.org Signed-off-by: Amos Kong Reviewed-by: Markus Armbruster Signed-off-by: Andreas Färber (cherry picked from commit ce0abca3e35a9f95e9edcb5d6b2910b2fcd52099) Signed-off-by: Michael Roth --- qdev-monitor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qdev-monitor.c b/qdev-monitor.c index 9268c87..40c117d 100644 --- a/qdev-monitor.c +++ b/qdev-monitor.c @@ -206,7 +206,7 @@ int qdev_device_help(QemuOpts *opts) } } - if (!klass) { + if (!object_class_dynamic_cast(klass, TYPE_DEVICE)) { return 0; } do { -- 1.9.1