All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cao jin <caoj.fnst@cn.fujitsu.com>
To: qemu-devel@nongnu.org
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
	Marcel Apfelbaum <marcel@redhat.com>
Subject: [Qemu-devel] [PATCH RFC] pci: call PCIDeviceClass->exit on its .realize failure
Date: Wed, 14 Sep 2016 17:14:26 +0800	[thread overview]
Message-ID: <1473844466-17458-1-git-send-email-caoj.fnst@cn.fujitsu.com> (raw)

It cannot guarantee all pci devices will free the allocated resource in
its .realize function on realize failure.

CC: Michael S. Tsirkin <mst@redhat.com>
CC: Marcel Apfelbaum <marcel@redhat.com>
Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
---

I found not all the devices will free the allocated resources on .realize
failure, and .exit function is the one who take responsibility to free all
the resource. In theory, I think it should be PCIDeviceClass->exit who does
the cleanup on realize failure, with appropriate check whether certain
resources is allocated.
It passed make check, but maybe need more confirmation, so, RFC.

 hw/pci/pci.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 24fae16..4b63a79 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -1967,6 +1967,9 @@ static void pci_qdev_realize(DeviceState *qdev, Error **errp)
         if (local_err) {
             error_propagate(errp, local_err);
             do_pci_unregister_device(pci_dev);
+            if (pc->exit) {
+                pc->exit(pci_dev);
+            }
             return;
         }
     }
-- 
2.1.0

             reply	other threads:[~2016-09-14  9:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-14  9:14 Cao jin [this message]
2016-09-14 11:59 ` [Qemu-devel] [PATCH RFC] pci: call PCIDeviceClass->exit on its .realize failure Marcel Apfelbaum
2016-09-19  6:16   ` Cao jin

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=1473844466-17458-1-git-send-email-caoj.fnst@cn.fujitsu.com \
    --to=caoj.fnst@cn.fujitsu.com \
    --cc=marcel@redhat.com \
    --cc=mst@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.