mirror of https://github.com/xqemu/xqemu.git
virtio: check virtio_load return code
Otherwise we crash on error. Signed-off-by: Ulrich Obergfell <uobergfe@redhat.com> Signed-off-by: Orit Wassermann <owasserm@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
a6c5c84ae2
commit
2a633c461e
|
@ -211,11 +211,15 @@ static void virtio_balloon_save(QEMUFile *f, void *opaque)
|
||||||
static int virtio_balloon_load(QEMUFile *f, void *opaque, int version_id)
|
static int virtio_balloon_load(QEMUFile *f, void *opaque, int version_id)
|
||||||
{
|
{
|
||||||
VirtIOBalloon *s = opaque;
|
VirtIOBalloon *s = opaque;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (version_id != 1)
|
if (version_id != 1)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
virtio_load(&s->vdev, f);
|
ret = virtio_load(&s->vdev, f);
|
||||||
|
if (ret) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
s->num_pages = qemu_get_be32(f);
|
s->num_pages = qemu_get_be32(f);
|
||||||
s->actual = qemu_get_be32(f);
|
s->actual = qemu_get_be32(f);
|
||||||
|
|
|
@ -533,11 +533,16 @@ static void virtio_blk_save(QEMUFile *f, void *opaque)
|
||||||
static int virtio_blk_load(QEMUFile *f, void *opaque, int version_id)
|
static int virtio_blk_load(QEMUFile *f, void *opaque, int version_id)
|
||||||
{
|
{
|
||||||
VirtIOBlock *s = opaque;
|
VirtIOBlock *s = opaque;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (version_id != 2)
|
if (version_id != 2)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
virtio_load(&s->vdev, f);
|
ret = virtio_load(&s->vdev, f);
|
||||||
|
if (ret) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
while (qemu_get_sbyte(f)) {
|
while (qemu_get_sbyte(f)) {
|
||||||
VirtIOBlockReq *req = virtio_blk_alloc_request(s);
|
VirtIOBlockReq *req = virtio_blk_alloc_request(s);
|
||||||
qemu_get_buffer(f, (unsigned char*)&req->elem, sizeof(req->elem));
|
qemu_get_buffer(f, (unsigned char*)&req->elem, sizeof(req->elem));
|
||||||
|
|
|
@ -891,11 +891,15 @@ static int virtio_net_load(QEMUFile *f, void *opaque, int version_id)
|
||||||
{
|
{
|
||||||
VirtIONet *n = opaque;
|
VirtIONet *n = opaque;
|
||||||
int i;
|
int i;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (version_id < 2 || version_id > VIRTIO_NET_VM_VERSION)
|
if (version_id < 2 || version_id > VIRTIO_NET_VM_VERSION)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
virtio_load(&n->vdev, f);
|
ret = virtio_load(&n->vdev, f);
|
||||||
|
if (ret) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
qemu_get_buffer(f, n->mac, ETH_ALEN);
|
qemu_get_buffer(f, n->mac, ETH_ALEN);
|
||||||
n->tx_waiting = qemu_get_be32(f);
|
n->tx_waiting = qemu_get_be32(f);
|
||||||
|
|
|
@ -564,7 +564,12 @@ static void virtio_scsi_save(QEMUFile *f, void *opaque)
|
||||||
static int virtio_scsi_load(QEMUFile *f, void *opaque, int version_id)
|
static int virtio_scsi_load(QEMUFile *f, void *opaque, int version_id)
|
||||||
{
|
{
|
||||||
VirtIOSCSI *s = opaque;
|
VirtIOSCSI *s = opaque;
|
||||||
virtio_load(&s->vdev, f);
|
int ret;
|
||||||
|
|
||||||
|
ret = virtio_load(&s->vdev, f);
|
||||||
|
if (ret) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -637,13 +637,17 @@ static int virtio_serial_load(QEMUFile *f, void *opaque, int version_id)
|
||||||
VirtIOSerialPort *port;
|
VirtIOSerialPort *port;
|
||||||
uint32_t max_nr_ports, nr_active_ports, ports_map;
|
uint32_t max_nr_ports, nr_active_ports, ports_map;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (version_id > 3) {
|
if (version_id > 3) {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The virtio device */
|
/* The virtio device */
|
||||||
virtio_load(&s->vdev, f);
|
ret = virtio_load(&s->vdev, f);
|
||||||
|
if (ret) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
if (version_id < 2) {
|
if (version_id < 2) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue