All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexey Kardashevskiy <aik@ozlabs.ru>
To: qemu-devel@nongnu.org
Cc: Alexey Kardashevskiy <aik@ozlabs.ru>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Igor Mammedov <imammedo@redhat.com>
Subject: [Qemu-devel] [PATCH qemu v2 2/2] object: Handle objects with no parents
Date: Mon, 30 Apr 2018 16:25:36 +1000	[thread overview]
Message-ID: <20180430062536.49077-3-aik@ozlabs.ru> (raw)
In-Reply-To: <20180430062536.49077-1-aik@ozlabs.ru>

At the moment object_get_canonical_path_component() crashes on assert()
if the object does not have a parent. Usually it is not called for
orphan objects but various HMP/QMP commands can do that (info mtree,
qom-get).

This adds few more tests in object_get_canonical_path() to prevent QEMU
from crashing.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
 qom/object.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qom/object.c b/qom/object.c
index 4677951..e0e300b 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -1668,7 +1668,7 @@ gchar *object_get_canonical_path(Object *obj)
     Object *root = object_get_root();
     char *newpath, *path = NULL;
 
-    while (obj != root) {
+    while (obj && obj->parent && obj != root) {
         char *component = object_get_canonical_path_component(obj);
 
         if (path) {
-- 
2.11.0

  parent reply	other threads:[~2018-04-30  6:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-30  6:25 [Qemu-devel] [PATCH qemu v2 0/2] memory/hmp: Print owners/parents in "info mtree" Alexey Kardashevskiy
2018-04-30  6:25 ` [Qemu-devel] [PATCH qemu v2 1/2] " Alexey Kardashevskiy
2018-04-30  9:53   ` Paolo Bonzini
2018-05-03  5:40     ` Alexey Kardashevskiy
2018-05-30  4:57       ` Alexey Kardashevskiy
2018-05-30 10:30         ` Paolo Bonzini
2018-04-30  6:25 ` Alexey Kardashevskiy [this message]
2018-04-30  9:51   ` [Qemu-devel] [PATCH qemu v2 2/2] object: Handle objects with no parents Paolo Bonzini

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=20180430062536.49077-3-aik@ozlabs.ru \
    --to=aik@ozlabs.ru \
    --cc=armbru@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=pbonzini@redhat.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.