From patchwork Tue Apr 30 13:02:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 240615 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 4E9B42C00BC for ; Tue, 30 Apr 2013 23:31:10 +1000 (EST) Received: from localhost ([::1]:46410 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UXAeC-000349-IY for incoming@patchwork.ozlabs.org; Tue, 30 Apr 2013 09:31:08 -0400 Received: from eggs.gnu.org ([208.118.235.92]:47105) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UXAdo-0002zV-K7 for qemu-devel@nongnu.org; Tue, 30 Apr 2013 09:30:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UXAdm-0007dg-PL for qemu-devel@nongnu.org; Tue, 30 Apr 2013 09:30:44 -0400 Received: from cantor2.suse.de ([195.135.220.15]:40071 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UXACH-0006aq-QK for qemu-devel@nongnu.org; Tue, 30 Apr 2013 09:02:17 -0400 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id C4214A41E0; Tue, 30 Apr 2013 15:02:16 +0200 (CEST) From: Alexander Graf To: qemu-devel@nongnu.org Date: Tue, 30 Apr 2013 15:02:16 +0200 Message-Id: <1367326936-28539-1-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.6.0.2 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-Received-From: 195.135.220.15 Cc: pbonzini@redhat.com, aliguori@us.ibm.com, av1474@comtv.ru, dingel@linux.vnet.ibm.com, borntraeger@de.ibm.com Subject: [Qemu-devel] [PATCH] QOM: Fail casts for unknown types X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org When we try to cast an object to an unknown type, fail the cast. Today we would simply run into an assert(). This fixes a bug on qemu-system-s390x for me that gets triggered by the audio code looking for PCI and ISA buses. Signed-off-by: Alexander Graf Reviewed-by: Paolo Bonzini Reviewed-by: Andreas Färber --- qom/object.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/qom/object.c b/qom/object.c index dd53d24..75e6aac 100644 --- a/qom/object.c +++ b/qom/object.c @@ -453,6 +453,11 @@ ObjectClass *object_class_dynamic_cast(ObjectClass *class, TypeImpl *type = class->type; ObjectClass *ret = NULL; + if (!target_type) { + /* target class type unknown, so fail the cast */ + return NULL; + } + if (type->class->interfaces && type_is_ancestor(target_type, type_interface)) { int found = 0;