* [Qemu-devel] [PATCH] QOM: Fail casts for unknown types
@ 2013-04-30 13:02 Alexander Graf
2013-04-30 13:57 ` Paolo Bonzini
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Alexander Graf @ 2013-04-30 13:02 UTC (permalink / raw)
To: qemu-devel; +Cc: pbonzini, aliguori, av1474, dingel, borntraeger
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 <agraf@suse.de>
---
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;
--
1.6.0.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] QOM: Fail casts for unknown types
2013-04-30 13:02 [Qemu-devel] [PATCH] QOM: Fail casts for unknown types Alexander Graf
@ 2013-04-30 13:57 ` Paolo Bonzini
2013-04-30 14:58 ` Andreas Färber
2013-04-30 18:58 ` Anthony Liguori
2 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2013-04-30 13:57 UTC (permalink / raw)
To: Alexander Graf; +Cc: borntraeger, aliguori, av1474, qemu-devel, dingel
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 <agraf@suse.de>
Seems a better solution than guarding the object_resolve_path_type with
an if.
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
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;
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] QOM: Fail casts for unknown types
2013-04-30 13:02 [Qemu-devel] [PATCH] QOM: Fail casts for unknown types Alexander Graf
2013-04-30 13:57 ` Paolo Bonzini
@ 2013-04-30 14:58 ` Andreas Färber
2013-04-30 18:58 ` Anthony Liguori
2 siblings, 0 replies; 4+ messages in thread
From: Andreas Färber @ 2013-04-30 14:58 UTC (permalink / raw)
To: Alexander Graf
Cc: aliguori, qemu-devel, dingel, borntraeger, av1474, pbonzini
Am 30.04.2013 15:02, schrieb Alexander Graf:
> 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 <agraf@suse.de>
Reviewed-by: Andreas Färber <afaerber@suse.de>
but "qom: ..." please, for proportional (Web) fonts. :)
Andreas
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] QOM: Fail casts for unknown types
2013-04-30 13:02 [Qemu-devel] [PATCH] QOM: Fail casts for unknown types Alexander Graf
2013-04-30 13:57 ` Paolo Bonzini
2013-04-30 14:58 ` Andreas Färber
@ 2013-04-30 18:58 ` Anthony Liguori
2 siblings, 0 replies; 4+ messages in thread
From: Anthony Liguori @ 2013-04-30 18:58 UTC (permalink / raw)
To: Alexander Graf, qemu-devel
Cc: aliguori, dingel, borntraeger, av1474, pbonzini
Applied. Thanks.
Regards,
Anthony Liguori
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-04-30 18:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-30 13:02 [Qemu-devel] [PATCH] QOM: Fail casts for unknown types Alexander Graf
2013-04-30 13:57 ` Paolo Bonzini
2013-04-30 14:58 ` Andreas Färber
2013-04-30 18:58 ` Anthony Liguori
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).