From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:57913) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UXB42-0003xN-MX for qemu-devel@nongnu.org; Tue, 30 Apr 2013 09:57:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UXB40-0001GP-Ec for qemu-devel@nongnu.org; Tue, 30 Apr 2013 09:57:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:5008) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UXB40-0001Fz-4R for qemu-devel@nongnu.org; Tue, 30 Apr 2013 09:57:48 -0400 Message-ID: <517FCDC0.4090000@redhat.com> Date: Tue, 30 Apr 2013 15:57:20 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1367326936-28539-1-git-send-email-agraf@suse.de> In-Reply-To: <1367326936-28539-1-git-send-email-agraf@suse.de> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] QOM: Fail casts for unknown types List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexander Graf Cc: borntraeger@de.ibm.com, aliguori@us.ibm.com, av1474@comtv.ru, qemu-devel@nongnu.org, dingel@linux.vnet.ibm.com Il 30/04/2013 15:02, Alexander Graf ha scritto: > 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 Seems a better solution than guarding the object_resolve_path_type with an if. Reviewed-by: Paolo Bonzini Paolo > --- > 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; >