From: Rusty Russell <rusty@rustcorp.com.au>
Cc: Amit Shah <amit.shah@redhat.com>,
Mark McLoughlin <markmc@redhat.com>,
Virtualization List <virtualization@lists.linux-foundation.org>,
"Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [PATCH] virtio_pci: Prevent double-free of pci regions after device hot-unplug
Date: Wed, 16 Mar 2011 14:34:58 +1030 [thread overview]
Message-ID: <871v27iuc5.fsf@rustcorp.com.au> (raw)
In-Reply-To: <f3e00b6450ee110e9dbe794d42ae058758e64d07.1300104900.git.amit.shah@redhat.com>
On Mon, 14 Mar 2011 17:45:02 +0530, Amit Shah <amit.shah@redhat.com> wrote:
> In the case where a virtio-console port is in use (opened by a program)
> and a virtio-console device is removed, the port is kept around but all
> the virtio-related state is assumed to be gone.
>
> When the port is finally released (close() called), we call
> device_destroy() on the port's device. This results in the parent
> device's structures to be freed as well. This includes the PCI regions
> for the virtio-console PCI device.
>
> Once this is done, however, virtio_pci_release_dev() kicks in, as the
> last ref to the virtio device is now gone, and attempts to do
>
> pci_iounmap(pci_dev, vp_dev->ioaddr);
> pci_release_regions(pci_dev);
> pci_disable_device(pci_dev);
>
> which results in a double-free warning.
>
> Move the code that releases regions, etc., to the virtio_pci_remove()
> function, and all that's now left in release_dev is the final freeing of
> the vp_dev.
>
> Signed-off-by: Amit Shah <amit.shah@redhat.com>
Applied.
Thanks,
Rusty.
prev parent reply other threads:[~2011-03-16 4:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-14 12:15 [PATCH] virtio_pci: Prevent double-free of pci regions after device hot-unplug Amit Shah
2011-03-16 4:04 ` Rusty Russell [this message]
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=871v27iuc5.fsf@rustcorp.com.au \
--to=rusty@rustcorp.com.au \
--cc=amit.shah@redhat.com \
--cc=markmc@redhat.com \
--cc=mst@redhat.com \
--cc=virtualization@lists.linux-foundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox