From: Yuri Benditovich <yuri.benditovich@daynix.com>
To: qemu-devel@nongnu.org, mst@redhat.com
Cc: yan@daynix.com
Subject: [PATCH v2 1/2] virtio-pci: add check for vdev in virtio_pci_isr_read
Date: Mon, 15 Mar 2021 13:59:36 +0200 [thread overview]
Message-ID: <20210315115937.14286-2-yuri.benditovich@daynix.com> (raw)
In-Reply-To: <20210315115937.14286-1-yuri.benditovich@daynix.com>
https://bugzilla.redhat.com/show_bug.cgi?id=1743098
This commit completes the solution of segfault in hot unplug flow
(by commit ccec7e9603f446fe75c6c563ba335c00cfda6a06).
Added missing check for vdev in virtio_pci_isr_read.
Typical stack of crash:
virtio_pci_isr_read ../hw/virtio/virtio-pci.c:1365 with proxy-vdev = 0
memory_region_read_accessor at ../softmmu/memory.c:442
access_with_adjusted_size at ../softmmu/memory.c:552
memory_region_dispatch_read1 at ../softmmu/memory.c:1420
memory_region_dispatch_read at ../softmmu/memory.c:1449
flatview_read_continue at ../softmmu/physmem.c:2822
flatview_read at ../softmmu/physmem.c:2862
address_space_read_full at ../softmmu/physmem.c:2875
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
---
hw/virtio/virtio-pci.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 883045a223..4a3dcee771 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -1364,9 +1364,14 @@ static uint64_t virtio_pci_isr_read(void *opaque, hwaddr addr,
{
VirtIOPCIProxy *proxy = opaque;
VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
- uint64_t val = qatomic_xchg(&vdev->isr, 0);
- pci_irq_deassert(&proxy->pci_dev);
+ uint64_t val;
+
+ if (vdev == NULL) {
+ return 0;
+ }
+ val = qatomic_xchg(&vdev->isr, 0);
+ pci_irq_deassert(&proxy->pci_dev);
return val;
}
--
2.17.1
next prev parent reply other threads:[~2021-03-15 12:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-15 11:59 [PATCH v2 0/2] virtio-pci: add check for vdev in virtio_pci_isr_read Yuri Benditovich
2021-03-15 11:59 ` Yuri Benditovich [this message]
2021-03-23 19:51 ` [PATCH v2 1/2] " Yuri Benditovich
2021-03-15 11:59 ` [PATCH v2 2/2] virtio-pci: remove explicit initialization of val Yuri Benditovich
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=20210315115937.14286-2-yuri.benditovich@daynix.com \
--to=yuri.benditovich@daynix.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=yan@daynix.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).