diff mbox

[for-1.4] s390-virtio: Check for NULL device in reset hypercall

Message ID 1358933048-17823-1-git-send-email-afaerber@suse.de
State New
Headers show

Commit Message

Andreas Färber Jan. 23, 2013, 9:24 a.m. UTC
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).

Cc: qemu-stable@nongnu.org
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 hw/s390-virtio.c |    3 +++
 1 Datei geändert, 3 Zeilen hinzugefügt(+)

Comments

Alexander Graf Jan. 25, 2013, 11:29 a.m. UTC | #1
On 23.01.2013, at 10:24, Andreas Färber wrote:

> 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).
> 
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Andreas Färber <afaerber@suse.de>

Thanks, applied to s390-next.


Alex
diff mbox

Patch

diff --git a/hw/s390-virtio.c b/hw/s390-virtio.c
index 5edaabb..5d48aba 100644
--- a/hw/s390-virtio.c
+++ b/hw/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);