All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: peter.crosthwaite@xilinx.com
Cc: edgar.iglesias@gmail.com, aliguori@us.ibm.com,
	qemu-devel@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v1 1/1] qom/object: Don't poll cast cache for NULL objects
Date: Tue, 21 May 2013 13:36:50 +0200	[thread overview]
Message-ID: <519B5C52.60802@suse.de> (raw)
In-Reply-To: <feaf19cbe63980b483e31d91a0c1e2bb433eae37.1369115958.git.peter.crosthwaite@xilinx.com>

Am 21.05.2013 08:05, schrieb peter.crosthwaite@xilinx.com:
> From: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
> 
> object_dymamic_cast_assert used to be tolerant of NULL objects and not

"dynamic"

> assert. Its clear from the implementation that this is the expected

"It's"

> 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>

Otherwise,

Reviewed-by: Andreas Färber <afaerber@suse.de>

Andreas

> ---
> 
>  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];
>          }
> 

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

  reply	other threads:[~2013-05-21 11:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-21  6:05 [Qemu-devel] [PATCH v1 1/1] qom/object: Don't poll cast cache for NULL objects peter.crosthwaite
2013-05-21 11:36 ` Andreas Färber [this message]
2013-05-21 12:01 ` Anthony Liguori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=519B5C52.60802@suse.de \
    --to=afaerber@suse.de \
    --cc=aliguori@us.ibm.com \
    --cc=edgar.iglesias@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.crosthwaite@xilinx.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.