All of lore.kernel.org
 help / color / mirror / Atom feed
From: Weidong Han <weidong.han@intel.com>
To: avi@redhat.com, paul@codesourcery.com
Cc: kvm@vger.kernel.org, Weidong Han <weidong.han@intel.com>
Subject: [PATCH RFC] qemu: fix hot remove assigned device
Date: Tue,  9 Jun 2009 01:17:15 +0800	[thread overview]
Message-ID: <1244481435-17224-1-git-send-email-weidong.han@intel.com> (raw)

When hot remove an assigned device, segmentation fault was triggered
by qemu_free(&pci_dev->qdev) in pci_unregister_device().
pci_register_device() doesn't initialize or set pci_dev->qdev. For an
assigned device, qdev variable isn't touched at all. So segmentation
fault happens when to free a non-initialized qdev.

Paul,
you introduced the code to free qdev in pci_unregiser_device. Did you
miss something?

Following patch changes the code back to free pci_dev, and fixes the
hot remove issue.

Signed-off-by: Weidong Han <weidong.han@intel.com>
---
 hw/pci.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/hw/pci.c b/hw/pci.c
index 25581a4..77d63d8 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -377,7 +377,7 @@ int pci_unregister_device(PCIDevice *pci_dev)
     qemu_free_irqs(pci_dev->irq);
     pci_irq_index--;
     pci_dev->bus->devices[pci_dev->devfn] = NULL;
-    qdev_free(&pci_dev->qdev);
+    qemu_free(pci_dev);
     return 0;
 }
 
-- 
1.6.0.4


             reply	other threads:[~2009-06-08  9:17 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-08 17:17 Weidong Han [this message]
2009-06-08 14:38 ` [PATCH RFC] qemu: fix hot remove assigned device Paul Brook
2009-06-09  2:45   ` Han, Weidong
2009-06-09 14:51     ` Paul Brook
2009-06-09 15:37       ` Gerd Hoffmann
2009-06-10  7:45         ` Han, Weidong
2009-06-10  8:06           ` Avi Kivity
2009-06-10  8:31             ` Han, Weidong
2009-06-10  8:42               ` Avi Kivity
2009-06-10  8:49               ` Gerd Hoffmann
2009-06-10  8:55                 ` Han, Weidong

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=1244481435-17224-1-git-send-email-weidong.han@intel.com \
    --to=weidong.han@intel.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=paul@codesourcery.com \
    /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.