aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorAndreas Färber <afaerber@suse.de>2013-01-22 23:24:08 +0000
committerAlexander Graf <agraf@suse.de>2013-01-29 21:50:04 +0100
commitab290630fad0df42ee94a81b20c48d0da2dc6f66 (patch)
tree0705648901192d9cf15e94e40e177ac7a45f655f /hw
parentb73d35311098585dbdb375fdf8369b16c8222e12 (diff)
s390-virtio: Check for NULL device in reset hypercall
s390_virtio_bus_find_mem() may return a NULL VirtIOS390Device. If called with, e.g., args[0] == 0, this leads to a segfault. Fix this by adding error handling as done for other hypercalls. Present since baf0b55a9e57b909b1f8b0f732c0b10242867418 (Implement virtio reset). Signed-off-by: Andreas Färber <afaerber@suse.de> Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'hw')
-rw-r--r--hw/s390x/s390-virtio.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c
index a8a489dc3e..2a1d9ac2da 100644
--- a/hw/s390x/s390-virtio.c
+++ b/hw/s390x/s390-virtio.c
@@ -86,6 +86,9 @@ static int s390_virtio_hcall_reset(const uint64_t *args)
VirtIOS390Device *dev;
dev = s390_virtio_bus_find_mem(s390_bus, mem);
+ if (dev == NULL) {
+ return -EINVAL;
+ }
virtio_reset(dev->vdev);
stb_phys(dev->dev_offs + VIRTIO_DEV_OFFS_STATUS, 0);
s390_virtio_device_sync(dev);