qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2 1/1] qom/object: Don't poll cast cache for NULL objects
@ 2013-05-22  1:19 peter.crosthwaite
  2013-05-22  6:04 ` Paolo Bonzini
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: peter.crosthwaite @ 2013-05-22  1:19 UTC (permalink / raw)
  To: qemu-devel; +Cc: edgar.iglesias, aliguori, afaerber, pbonzini

From: Peter Crosthwaite <peter.crosthwaite@xilinx.com>

object_dynamic_cast_assert used to be tolerant of NULL objects and not
assert. It's clear from the implementation that this is the expected
behavior.

The preceding check of the cast cache dereferences obj however causing
a segfault. Fix by conditionalizing the cast cache logic on obj being
non-null.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
---
Changed from v1: Fixed 2 commit msg typos (AF review)

 qom/object.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/qom/object.c b/qom/object.c
index ec88231..803b94b 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -442,7 +442,7 @@ Object *object_dynamic_cast_assert(Object *obj, const char *typename,
     int i;
     Object *inst;
 
-    for (i = 0; i < OBJECT_CLASS_CAST_CACHE; i++) {
+    for (i = 0; obj && i < OBJECT_CLASS_CAST_CACHE; i++) {
         if (obj->class->cast_cache[i] == typename) {
             goto out;
         }
@@ -458,7 +458,7 @@ Object *object_dynamic_cast_assert(Object *obj, const char *typename,
 
     assert(obj == inst);
 
-    if (obj == inst) {
+    if (obj && obj == inst) {
         for (i = 1; i < OBJECT_CLASS_CAST_CACHE; i++) {
             obj->class->cast_cache[i - 1] = obj->class->cast_cache[i];
         }
-- 
1.8.3.rc1.44.gb387c77.dirty

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH v2 1/1] qom/object: Don't poll cast cache for NULL objects
  2013-05-22  1:19 [Qemu-devel] [PATCH v2 1/1] qom/object: Don't poll cast cache for NULL objects peter.crosthwaite
@ 2013-05-22  6:04 ` Paolo Bonzini
  2013-05-22  6:16 ` Edgar E. Iglesias
  2013-05-22 22:58 ` Anthony Liguori
  2 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2013-05-22  6:04 UTC (permalink / raw)
  To: peter crosthwaite
  Cc: edgar iglesias, aliguori, qemu-stable, qemu-devel, afaerber



----- Messaggio originale -----
> Da: "peter crosthwaite" <peter.crosthwaite@xilinx.com>
> A: qemu-devel@nongnu.org
> Cc: aliguori@us.ibm.com, "edgar iglesias" <edgar.iglesias@gmail.com>, pbonzini@redhat.com, afaerber@suse.de
> Inviato: Mercoledì, 22 maggio 2013 3:19:16
> Oggetto: [PATCH v2 1/1] qom/object: Don't poll cast cache for NULL objects
> 
> From: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
> 
> object_dynamic_cast_assert used to be tolerant of NULL objects and not
> assert. It's clear from the implementation that this is the expected
> behavior.
> 
> The preceding check of the cast cache dereferences obj however causing
> a segfault. Fix by conditionalizing the cast cache logic on obj being
> non-null.
> 
> Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
> Reviewed-by: Andreas Färber <afaerber@suse.de>
> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
> ---
> Changed from v1: Fixed 2 commit msg typos (AF review)
> 
>  qom/object.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/qom/object.c b/qom/object.c
> index ec88231..803b94b 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -442,7 +442,7 @@ Object *object_dynamic_cast_assert(Object *obj, const
> char *typename,
>      int i;
>      Object *inst;
>  
> -    for (i = 0; i < OBJECT_CLASS_CAST_CACHE; i++) {
> +    for (i = 0; obj && i < OBJECT_CLASS_CAST_CACHE; i++) {
>          if (obj->class->cast_cache[i] == typename) {
>              goto out;
>          }
> @@ -458,7 +458,7 @@ Object *object_dynamic_cast_assert(Object *obj, const
> char *typename,
>  
>      assert(obj == inst);
>  
> -    if (obj == inst) {
> +    if (obj && obj == inst) {
>          for (i = 1; i < OBJECT_CLASS_CAST_CACHE; i++) {
>              obj->class->cast_cache[i - 1] = obj->class->cast_cache[i];
>          }
> --
> 1.8.3.rc1.44.gb387c77.dirty

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>

... and added qemu-stable@nongnu.org since this got in pretty close to a release.

Paolo

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH v2 1/1] qom/object: Don't poll cast cache for NULL objects
  2013-05-22  1:19 [Qemu-devel] [PATCH v2 1/1] qom/object: Don't poll cast cache for NULL objects peter.crosthwaite
  2013-05-22  6:04 ` Paolo Bonzini
@ 2013-05-22  6:16 ` Edgar E. Iglesias
  2013-05-22 22:58 ` Anthony Liguori
  2 siblings, 0 replies; 4+ messages in thread
From: Edgar E. Iglesias @ 2013-05-22  6:16 UTC (permalink / raw)
  To: peter.crosthwaite; +Cc: pbonzini, aliguori, qemu-devel, afaerber

On Wed, May 22, 2013 at 11:19:16AM +1000, peter.crosthwaite@xilinx.com wrote:
> From: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
> 
> object_dynamic_cast_assert used to be tolerant of NULL objects and not
> assert. It's clear from the implementation that this is the expected
> behavior.
> 
> The preceding check of the cast cache dereferences obj however causing
> a segfault. Fix by conditionalizing the cast cache logic on obj being
> non-null.
> 
> Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
> Reviewed-by: Andreas Färber <afaerber@suse.de>
> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>


Reviewed-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>


> ---
> Changed from v1: Fixed 2 commit msg typos (AF review)
> 
>  qom/object.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/qom/object.c b/qom/object.c
> index ec88231..803b94b 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -442,7 +442,7 @@ Object *object_dynamic_cast_assert(Object *obj, const char *typename,
>      int i;
>      Object *inst;
>  
> -    for (i = 0; i < OBJECT_CLASS_CAST_CACHE; i++) {
> +    for (i = 0; obj && i < OBJECT_CLASS_CAST_CACHE; i++) {
>          if (obj->class->cast_cache[i] == typename) {
>              goto out;
>          }
> @@ -458,7 +458,7 @@ Object *object_dynamic_cast_assert(Object *obj, const char *typename,
>  
>      assert(obj == inst);
>  
> -    if (obj == inst) {
> +    if (obj && obj == inst) {
>          for (i = 1; i < OBJECT_CLASS_CAST_CACHE; i++) {
>              obj->class->cast_cache[i - 1] = obj->class->cast_cache[i];
>          }
> -- 
> 1.8.3.rc1.44.gb387c77.dirty
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH v2 1/1] qom/object: Don't poll cast cache for NULL objects
  2013-05-22  1:19 [Qemu-devel] [PATCH v2 1/1] qom/object: Don't poll cast cache for NULL objects peter.crosthwaite
  2013-05-22  6:04 ` Paolo Bonzini
  2013-05-22  6:16 ` Edgar E. Iglesias
@ 2013-05-22 22:58 ` Anthony Liguori
  2 siblings, 0 replies; 4+ messages in thread
From: Anthony Liguori @ 2013-05-22 22:58 UTC (permalink / raw)
  To: peter.crosthwaite, qemu-devel
  Cc: aliguori, qemu-stable, pbonzini, edgar iglesias, afaerber

Applied.  Thanks.

Regards,

Anthony Liguori

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-05-22 22:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-22  1:19 [Qemu-devel] [PATCH v2 1/1] qom/object: Don't poll cast cache for NULL objects peter.crosthwaite
2013-05-22  6:04 ` Paolo Bonzini
2013-05-22  6:16 ` Edgar E. Iglesias
2013-05-22 22: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).