qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v1 1/1] qom: Fix class cast of NULL classes
@ 2013-06-18  9:18 peter.crosthwaite
  2013-06-18  9:53 ` Paolo Bonzini
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: peter.crosthwaite @ 2013-06-18  9:18 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, aliguori

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

Its clear from the implementation that class casting is supposed to work
with a NULL class argument. Guard all dereferences of the class argument
against NULL accordingly.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
---

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

diff --git a/qom/object.c b/qom/object.c
index 803b94b..b7ecb9f 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -531,14 +531,14 @@ ObjectClass *object_class_dynamic_cast_assert(ObjectClass *class,
 #ifdef CONFIG_QOM_CAST_DEBUG
     int i;
 
-    for (i = 0; i < OBJECT_CLASS_CAST_CACHE; i++) {
+    for (i = 0; class && i < OBJECT_CLASS_CAST_CACHE; i++) {
         if (class->cast_cache[i] == typename) {
             ret = class;
             goto out;
         }
     }
 #else
-    if (!class->interfaces) {
+    if (!class || !class->interfaces) {
         return class;
     }
 #endif
@@ -551,7 +551,7 @@ ObjectClass *object_class_dynamic_cast_assert(ObjectClass *class,
     }
 
 #ifdef CONFIG_QOM_CAST_DEBUG
-    if (ret == class) {
+    if (class && ret == class) {
         for (i = 1; i < OBJECT_CLASS_CAST_CACHE; i++) {
             class->cast_cache[i - 1] = 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 v1 1/1] qom: Fix class cast of NULL classes
  2013-06-18  9:18 [Qemu-devel] [PATCH v1 1/1] qom: Fix class cast of NULL classes peter.crosthwaite
@ 2013-06-18  9:53 ` Paolo Bonzini
  2013-07-10  5:17 ` Peter Crosthwaite
  2013-07-10 19:33 ` Anthony Liguori
  2 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2013-06-18  9:53 UTC (permalink / raw)
  To: peter.crosthwaite; +Cc: aliguori, qemu-devel, 1.5.x

Il 18/06/2013 11:18, peter.crosthwaite@xilinx.com ha scritto:
> From: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
> 
> Its clear from the implementation that class casting is supposed to work
> with a NULL class argument. Guard all dereferences of the class argument
> against NULL accordingly.
> 
> Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>

Cc: qemu-stable@nongnu.org


> ---
> 
>  qom/object.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/qom/object.c b/qom/object.c
> index 803b94b..b7ecb9f 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -531,14 +531,14 @@ ObjectClass *object_class_dynamic_cast_assert(ObjectClass *class,
>  #ifdef CONFIG_QOM_CAST_DEBUG
>      int i;
>  
> -    for (i = 0; i < OBJECT_CLASS_CAST_CACHE; i++) {
> +    for (i = 0; class && i < OBJECT_CLASS_CAST_CACHE; i++) {
>          if (class->cast_cache[i] == typename) {
>              ret = class;
>              goto out;
>          }
>      }
>  #else
> -    if (!class->interfaces) {
> +    if (!class || !class->interfaces) {
>          return class;
>      }
>  #endif
> @@ -551,7 +551,7 @@ ObjectClass *object_class_dynamic_cast_assert(ObjectClass *class,
>      }
>  
>  #ifdef CONFIG_QOM_CAST_DEBUG
> -    if (ret == class) {
> +    if (class && ret == class) {
>          for (i = 1; i < OBJECT_CLASS_CAST_CACHE; i++) {
>              class->cast_cache[i - 1] = class->cast_cache[i];
>          }
> 

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

* Re: [Qemu-devel] [PATCH v1 1/1] qom: Fix class cast of NULL classes
  2013-06-18  9:18 [Qemu-devel] [PATCH v1 1/1] qom: Fix class cast of NULL classes peter.crosthwaite
  2013-06-18  9:53 ` Paolo Bonzini
@ 2013-07-10  5:17 ` Peter Crosthwaite
  2013-07-10 19:33 ` Anthony Liguori
  2 siblings, 0 replies; 4+ messages in thread
From: Peter Crosthwaite @ 2013-07-10  5:17 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, aliguori

Ping!

On Tue, Jun 18, 2013 at 7:18 PM,  <peter.crosthwaite@xilinx.com> wrote:
> From: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
>
> Its clear from the implementation that class casting is supposed to work
> with a NULL class argument. Guard all dereferences of the class argument
> against NULL accordingly.
>
> Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
> ---
>
>  qom/object.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/qom/object.c b/qom/object.c
> index 803b94b..b7ecb9f 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -531,14 +531,14 @@ ObjectClass *object_class_dynamic_cast_assert(ObjectClass *class,
>  #ifdef CONFIG_QOM_CAST_DEBUG
>      int i;
>
> -    for (i = 0; i < OBJECT_CLASS_CAST_CACHE; i++) {
> +    for (i = 0; class && i < OBJECT_CLASS_CAST_CACHE; i++) {
>          if (class->cast_cache[i] == typename) {
>              ret = class;
>              goto out;
>          }
>      }
>  #else
> -    if (!class->interfaces) {
> +    if (!class || !class->interfaces) {
>          return class;
>      }
>  #endif
> @@ -551,7 +551,7 @@ ObjectClass *object_class_dynamic_cast_assert(ObjectClass *class,
>      }
>
>  #ifdef CONFIG_QOM_CAST_DEBUG
> -    if (ret == class) {
> +    if (class && ret == class) {
>          for (i = 1; i < OBJECT_CLASS_CAST_CACHE; i++) {
>              class->cast_cache[i - 1] = class->cast_cache[i];
>          }
> --
> 1.8.3.rc1.44.gb387c77.dirty
>

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

* Re: [Qemu-devel] [PATCH v1 1/1] qom: Fix class cast of NULL classes
  2013-06-18  9:18 [Qemu-devel] [PATCH v1 1/1] qom: Fix class cast of NULL classes peter.crosthwaite
  2013-06-18  9:53 ` Paolo Bonzini
  2013-07-10  5:17 ` Peter Crosthwaite
@ 2013-07-10 19:33 ` Anthony Liguori
  2 siblings, 0 replies; 4+ messages in thread
From: Anthony Liguori @ 2013-07-10 19:33 UTC (permalink / raw)
  To: peter.crosthwaite, qemu-devel; +Cc: pbonzini, aliguori, 1.5.x

Applied.  Thanks.

Regards,

Anthony Liguori

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

end of thread, other threads:[~2013-07-10 19:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-18  9:18 [Qemu-devel] [PATCH v1 1/1] qom: Fix class cast of NULL classes peter.crosthwaite
2013-06-18  9:53 ` Paolo Bonzini
2013-07-10  5:17 ` Peter Crosthwaite
2013-07-10 19:33 ` 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).