From: "Michael S. Tsirkin" <mst@redhat.com>
To: leixiang <leixiang@kylinos.cn>
Cc: qemu-devel@nongnu.org, xieming@kylinos.cn, zengchi@kylinos.cn
Subject: Re: [RESEND PATCH] virtio-pci: fix vector_irqfd leak in virtio_pci_set_guest_notifiers
Date: Tue, 20 Dec 2022 09:42:26 -0500 [thread overview]
Message-ID: <20221220093838-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20221130055611.1037023-1-leixiang@kylinos.cn>
On Wed, Nov 30, 2022 at 01:56:11PM +0800, leixiang wrote:
> proxy->vector_irqfd did not free when set guest notifier failed.
Can you pls add a Fixes tag so people know where to backport this?
> Signed-off-by: Lei Xiang <leixiang@kylinos.cn>
> Tested-by: Zeng Chi <zengchi@kylinos.cn>
> Suggested-by: Xie Ming <xieming@kylinos.cn>
Looking at the code I see this:
/* Must set vector notifier after guest notifier has been assigned */
if ((with_irqfd ||
(vdev->use_guest_notifier_mask && k->guest_notifier_mask)) &&
assign) {
if (with_irqfd) {
proxy->vector_irqfd =
g_malloc0(sizeof(*proxy->vector_irqfd) *
msix_nr_vectors_allocated(&proxy->pci_dev));
r = kvm_virtio_pci_vector_vq_use(proxy, nvqs);
if (r < 0) {
goto config_assign_error;
}
r = kvm_virtio_pci_vector_config_use(proxy);
if (r < 0) {
goto config_error;
}
}
r = msix_set_vector_notifiers(&proxy->pci_dev, virtio_pci_vector_unmask,
virtio_pci_vector_mask,
virtio_pci_vector_poll);
if (r < 0) {
goto notifiers_error;
}
}
doesn't this mean g_free belongs at the label config_assign_error?
> ---
> hw/virtio/virtio-pci.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
> index c6b47a9c..4862f83b 100644
> --- a/hw/virtio/virtio-pci.c
> +++ b/hw/virtio/virtio-pci.c
> @@ -1038,6 +1038,12 @@ assign_error:
> while (--n >= 0) {
> virtio_pci_set_guest_notifier(d, n, !assign, with_irqfd);
> }
> +
> + g_free(proxy->vector_irqfd);
> + proxy->vector_irqfd = NULL;
> +
> return r;
> }
>
> --
>
>
> No virus found
> Checked by Hillstone Network AntiVirus
The patch is corrupted. Line counts are wrong, and your antivirus added
trash at the end.
--
MST
next prev parent reply other threads:[~2022-12-20 14:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-09 0:25 [PATCH] virtio-pci: fix vector_irqfd leak in virtio_pci_set_guest_notifiers Lei Xiang
2022-08-26 3:06 ` [RESEND PATCH] " leixiang
2022-11-30 5:52 ` leixiang
2022-11-30 5:56 ` leixiang
2022-11-30 6:59 ` Michael S. Tsirkin
2022-12-20 14:42 ` Michael S. Tsirkin [this message]
2022-12-27 8:16 ` [RESEND PATCH] virtio-pci: fix proxy->vector_irqfd " leixiang
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=20221220093838-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=leixiang@kylinos.cn \
--cc=qemu-devel@nongnu.org \
--cc=xieming@kylinos.cn \
--cc=zengchi@kylinos.cn \
/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.